sling blade Level: Guest

|
LoadResource Function
Hello,
I use VB6 and I am have trouble using the LoadResource function to pull a string (MachineID) out of a text file.
I’m using the FindResource function to return a handle to a resource
string inside of the .res file. The FindResource function seems to
work as it is populated with a long type number. I then
use the handle from the FindResource function and try to get the string using the LoadResource function.
However, when I use the LoadResouce function I get an 'Overflow' error
message.
Any help would be great as I am stuck on what to try.
Below is my code:
Private Function LoadMachineID() As String
Dim hMachineID As Long
Dim hMem As Long, hResource As Long
On Error GoTo errhandler:
hResource = FindResource(0, "PALICENSELINKMACHINEID", "#10")
‘====This portion seems to work OK as hResource returns a long======
If hResource Then
‘====The code falls over here with ‘Overflow' error====
hMem = LoadResource(0, hResource)
If hMem Then
hMachineID = LockResource(hMem)
If hMachineID Then
LoadMachineID = hMachineID
Else
LoadMachineID = "abort"
End If
Else
LoadMachineID = "abort"
End If
Else
LoadMachineID = "abort"
End If
exithere:
Exit Function
errhandler:
MsgBox "Error in clsLicense.LoadMachineID: " & Err.Description & " " &
Err.Number
GoTo exithere:
End Function
|