Strange things in the land of globalmem...
The underlying code works in application A but not in application B
Especially the Poke$ doesn't work in another application. The calls are the
same.
In application B where above mentioned codesnippet doesn't work, this will but then this code won't work in application A.
I going nuts over this. ...
I want a general wrapper for global mem function that will work in every application.
The underlying code works in application A but not in application B
Especially the Poke$ doesn't work in another application. The calls are the
same.
Code:
Function malloc(ByVal sData As String) As Dword Local vStr As Dword ' String Ptr Local hPtr As Long Local hLock As Long If IsFalse(Len(sData)) Then Function = 0 Exit Function End If GlobalMem Alloc Len(sData) to hPtr GlobalMem Lock hPtr To vStr ' Need to use string pointer to allocate the string data instead of @vstr = sData (Bugfix) '@vStr = sData ' vStr = StrPtr(sData) Poke$ vStr, sData GlobalMem Unlock hPtr To hLock Function = hPtr End Function
Code:
Function malloc(ByVal sData As String) As Dword Local vStr As String ptr Local hPtr As Long Local hLock As Long If IsFalse(Len(sData)) Then Function = 0 Exit Function End If GlobalMem Alloc Len(sData) to hPtr GlobalMem Lock hPtr To vStr 'Poke$ vStr, sData @vStr = sData '@vStr = sData GlobalMem Unlock hPtr To hLock Function = hPtr End Function
I want a general wrapper for global mem function that will work in every application.
Comment