-
I *know* the answer to this; I just learned it a few days ago and now I can't remember.
When I call an API function that uses a pointer to a variable, I'm supposed to buffer the variable before it gets there. I can't remember the function to set the length of the variable!
e.g.
Code:
Dim sClsNm As String
'something goes here like setlen(sClsNm, 25)
Call GetClassName(hWnd, sClsNm, 25)
debug.print(sClsNm)
Will someone remind me?
Thanks,
--Josh
-
I don't know if this works for your API, but it works for GetPrivateProfileString
Dim sBuffer as String
Dim sResult as String
Dim nDummy as Integer
sBuffer = Space$(99)
nDummy = GetClassName(hWnd, sBuffer, 25)
sResult = Left$(sBuffer, nDummy)
-
-
Wait.. now how do I do it for a Long?
Thanks,
--Josh
-
a Long is always 45 Bytes. you can get the length of a variable in bytes using the LenB Function, eg
LenB(lngMyLong) will always return 4. There's no need to buffer longs fo the API, It's only Strings you need to do.
-
ah. found my bug (I *knew* that wasn't supposed to be a Long).
Thanks!