Results 1 to 11 of 11

Thread: [RESOLVED] Read Text file content from External DLL Resource file

Threaded View

  1. #1

    Thread Starter
    Addicted Member beic's Avatar
    Join Date
    Jun 2012
    Posts
    176

    Resolved [RESOLVED] Read Text file content from External DLL Resource file

    Hi there,

    I'm trying to load external text from my custom DLL resource file, but it's not working.

    Resource file content (Test.dll, Test.rc and Test.res containing Eula.txt), the Eula.txt file is about 6Kb:

    Code:
    900 CUSTOM  "Eula.txt"
    I'm using the code like this:
    Code:
    Private Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" (ByVal lpLibFileName As String) As Long  
    Private Declare Function LoadString Lib "user32" Alias "LoadStringA" (ByVal hInstance As Long, ByVal wID As Long, ByVal lpBuffer As String, ByVal nBufferMax As Long) As Long  
    Private Declare Function FreeLibrary Lib "kernel32" (ByVal hLibModule As Long) As Long
    Code:
    Public Function LoadStrRes(lgResID As Long) As String  
     On Error Resume Next  
       
     Dim lgRet As Long  
     Dim stBuff As String * 32768  
     Dim lgBuffPos As Long  
     Dim stFile As String  
       
     stFile = App.Path & "\Test.dll"  
       
     lgRet = LoadLibrary(stFile)  
      
     Call LoadString(lgRet, lgResID, stBuff, Len(stBuff))  
      
     lgBuffPos = InStr(1, stBuff, Chr$(0))  
      
     LoadStrRes = Left$(stBuff, lgBuffPos - 1)  
      
     Call FreeLibrary(lgRet)  
       
     Exit Function  
    End Function
    Calling the function like this:
    Code:
    Dim stTxtData As String  
       
    stTxtData = LoadStrRes(900)  
      
    txtEula.Text = stTxtData
    Can someone tell my why is it not working for me?

    Regards
    Last edited by beic; Jul 17th, 2014 at 03:08 PM. Reason: Code typo

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width