borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (Problem with Multiple instances)Next Topic (Reading data from ini files with VB5) New Topic New Poll Post Reply
AndreaVB Forum : VB General : LoadResource Function
Poster Message
sling blade
Level: Guest


icon 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

02-10-2004 at 08:02 AM
| Quote Reply
AndreaVB Forum : VB General : LoadResource Function
Previous Topic (Problem with Multiple instances)Next Topic (Reading data from ini files with VB5) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder