Author |
Message |
MrUnleaded Site Admin
Joined: 21 Sep 2002 Posts: 385 Location: California
|
Posted: Tue Oct 29, 2002 3:18 pm
Post subject: Loading Text File from Resource
|
|
Do you guys know how i can load and access a text file(all my opcodes)
I was attempting to use the Resource editor...but i was unable to load a text file into the string table.....and i was unable to access the correct data when i added the file as a "CUSTOM" resource entry.....
any one know how to do it? _________________ -MrU
|
|
Back to top |
|
|
|
Anonymous New User
Joined: 10 Feb 2008 Posts: 0
|
Posted: Tue Oct 29, 2002 5:02 pm
Post subject:
|
|
I believe you can use 'LoadResData' in VB to read resources.
|
|
Back to top |
|
|
|
Anonymous New User
Joined: 10 Feb 2008 Posts: 0
|
Posted: Wed Oct 30, 2002 11:31 am
Post subject:
|
|
A Cr+Lf seperated text file isnt a alid resource in this respect. You therefore cant use it :/ You can still do GetLine or whatever though. Get blah blah
|
|
Back to top |
|
|
|
napalm Site Admin
Joined: 11 Dec 2003 Posts: 18 Location: UK
|
Posted: Wed Dec 17, 2003 11:18 am
Post subject:
|
|
i know the posts above are old but i have made a module to deal with ResourceData Files you might find this helpful.
i hope i still know my phpBB codes been along time since i posted anything to anywhere.
-Napalm-
---------- snip mResFile.bas ----------
Code: |
Attribute VB_Name = "mResFile"
Private Declare Function GetTempPathA Lib "kernel32" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long
Private Declare Function GetSystemDirectoryA Lib "kernel32" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Private ResData() As Byte
Public Function ExtractResFile(ResID As Integer, Filename As String, _
Optional SaveToTempPath As Boolean = False, _
Optional SaveToSystem As Boolean = False) As String
On Error GoTo ResError
Dim FileHandle As Integer
If SaveToSystem Then Filename = GetSystemDirectory() & Filename
If SaveToTempPath Then Filename = GetTempPath() & Filename
ResData = LoadResData(ResID, "CUSTOM")
FileHandle = FreeFile
If FileExists(Filename) = False Then
Open Filename For Binary As FileHandle
Put FileHandle, , ResData
Close FileHandle
End If
ExtractResFile = Filename
Exit Function
ResError:
On Error Resume Next
Kill Filename
ExtractResFile = ""
On Error GoTo 0
End Function
Public Function FileExists(Filename As String) As Boolean
On Error GoTo nofile
Dim FileHandle As Integer
FileHandle = FreeFile
Open Filename For Input As FileHandle
Close FileHandle
FileExists = True
Exit Function
nofile:
FileExists = False
End Function
Public Function GetTempPath() As String
Dim strTemp As String
strTemp = String(255, 0)
GetTempPathA 255, strTemp
strTemp = Left$(strTemp, InStr(strTemp, Chr$(0)) - 1)
GetTempPath = strTemp
End Function
Public Function GetSystemDirectory() As String
Dim strTemp As String
strTemp = String(255, 0)
GetSystemDirectoryA strTemp, 255
strTemp = Left$(strTemp, InStr(strTemp, Chr$(0)) - 1)
GetSystemDirectory = strTemp
End Function
|
---------- snip mResFile.bas ----------
|
|
Back to top |
|
|
|
MrUnleaded Site Admin
Joined: 21 Sep 2002 Posts: 385 Location: California
|
Posted: Thu Dec 18, 2003 2:39 am
Post subject:
|
|
This is old....and i did figure it out. the reason i was not getting the correct data was because it was either 1.....stored in unicode and returned in ascii....or 2 stored in ascii and returned in unicode...
i think it is the StrConv() function that you can use to convert back and forth _________________ -MrU
|
|
Back to top |
|
|
|
|
|