Using String Resources
It’s unlikely that you’ll need to use string resources from a DLL or a program that you didn’t write, but it was so easy in 16-bit programs that WinWatch implemented it. Just pass the ID number of the string to the LoadString API function, along with a string buffer and a maximum length. The code looked something like this:
Dim c As Integer, s As String, id As Long
c = 256
s = Space$(c)
c = LoadString(hMod, Val(Mid$(sString, 2)), s, c)
If c <> 0 Then pbResource.Print WordWrap(Left$(s, c), 25)
Unfortunately, that didn’t work in 32-bit, and for a long time I couldn’t figure out why. Well, it turns out that many 32-bit resource strings are Unicode strings. I’m not sure how C programs are supposed to load Unicode string resources. It didn’t seem like something a Visual Basic programmer would want to spend time researching, so I just dumped them in hex format. It doesn’t do much good, but neither does it do any harm. The code for ShowString is almost exactly like the ShowData code we saw earlier.