when you use the dll importer there is created a special lib called SHLWAPI in folder [..]\PureBasic\PureLibraries\Windows\
this tool fixes this library so the purebasic compiler recognizes correct the functions as "StrFormatByteSizeA_()".
if you dont want to use my tool, because you don't want to run unknown exes (i understand why) you can hex-edit the mentioned file.
//EDIT:
btw: you can use the source, of course, and compile it yourself.
ERUPLLDE_Fixer.pb:
Code: Select all
; PureBasic Visual Designer v3.90 build 1360
#VERSION.s = "0.1"
IncludeFile "Common.pb"
IncludeFile "Util.pb"
Global sSourcePath$
Global sDestinationPath$
Open_Window_0()
LoadPrefs()
SetGadgetText(#String_0, sSourcePath$)
SetGadgetText(#String_1, sDestinationPath$)
Repeat
Event = WaitWindowEvent()
If Event = #PB_EventGadget
;Debug "WindowID: " + Str(EventWindowID())
GadgetID = EventGadgetID()
If GadgetID = #String_0
sSourcePath$ = GetGadgetText(#String_0)
ElseIf GadgetID = #String_1
sDestinationPath$ = GetGadgetText(#String_1)
ElseIf GadgetID = #Button_0
Debug "GadgetID: #Button_0"
If ExamineDirectory(#PB_Any, sDestinationPath$ + "PureLibraries\Windows\", "*.")
sPblFileName$ = OpenFileRequester("Please select .pbl File", "", "DLL Definifions (.pbl)|*.pbl", 0)
If sPblFileName$
GenerateERUPLLDE(sPblFileName$, sDestinationPath$ + "PureLibraries\Windows\")
Else
MessageRequester("Error", "Error while trying to fix!", #MB_ICONSTOP | #MB_OK)
EndIf
Else
MessageRequester("Error", "Is this the PureBasic path correct?", #MB_ICONSTOP | #MB_OK)
EndIf
SavePrefs()
ElseIf GadgetID = #Button_1
Debug "GadgetID: #Button_1"
Event = #PB_EventCloseWindow
ElseIf GadgetID = #Button_2
; PATH 1
Debug "GadgetID: #Button_2"
sTempSourcePath$ = PathRequester("Select the source directory", sSourcePath$)
If sTempSourcePath$
sSourcePath$ = sTempSourcePath$
SetGadgetText(#String_0, sSourcePath$)
EndIf
ElseIf GadgetID = #Button_3
Debug "GadgetID: #Button_3"
sTempDestinationPath$ = PathRequester("Select the destination directory", sDestinationPath$)
If sTempDestinationPath$
sDestinationPath$ = sTempDestinationPath$
SetGadgetText(#String_1, sDestinationPath$)
EndIf
EndIf
EndIf
Until Event = #PB_EventCloseWindow
End
Common.pb:
Code: Select all
;- Window Constants
;
Enumeration
#Window_0
EndEnumeration
;- Gadget Constants
;
Enumeration
#Text_0
#Text_1
#String_0
#String_1
#Button_0
#Button_1
#Button_2
#Button_3
#CheckBox_0
#Text_2
EndEnumeration
Procedure Open_Window_0()
If OpenWindow(#Window_0, 277, 328, 399, 121, #PB_Window_SystemMenu | #PB_Window_TitleBar , "ERUPLLDE Fixer v"+#VERSION)
If CreateGadgetList(WindowID())
TextGadget(#Text_0, 10, 10, 120, 20, "DLL Definition path :")
TextGadget(#Text_1, 10, 35, 115, 20, "PureBasic path :")
StringGadget(#String_0, 150, 10, 210, 20, "")
StringGadget(#String_1, 150, 35, 210, 20, "")
ButtonGadget(#Button_0, 10, 89, 190, 25, "Start")
ButtonGadget(#Button_1, 210, 89, 180, 25, "Quit")
ButtonGadget(#Button_2, 365, 10, 25, 20, "...")
ButtonGadget(#Button_3, 365, 35, 25, 20, "...")
EndIf
EndIf
EndProcedure
Util.pb:
Code: Select all
Enumeration
#PBL_File
#ERUPLLDE_File
#PREFS_File
EndEnumeration
Procedure.s ExePath()
ExePath$ = Space(1000)
GetModuleFileName_(0,@ExePath$,1000)
ProcedureReturn GetPathPart(ExePath$)
EndProcedure
Procedure.l GenerateERUPLLDE(sPblFileName$, sDestinationPath$)
Protected sDllName$
Protected sERUPLLDEName$
Protected sDestinationPath$
ReadFile(#PBL_File, sPblFileName$)
sDllName$ = Trim(ReadString())
Debug sDllName$
If UCase(Right(sDllName$, 4)) <> ".DLL"
MessageRequester("Error", "Malformed line. Should be in the form: DllName.DLL", #MB_ICONSTOP | #MB_OK)
ProcedureReturn #False
EndIf
sERUPLLDEName$ = Left(sDllName$, Len(sDllName$)-4)
DeleteFile(sDestinationPath$ + sERUPLLDEName$)
If OpenFile(#ERUPLLDE_File, sDestinationPath$ + sERUPLLDEName$)
WriteString("ERUPLLDE")
WriteByte(1)
WriteString(sERUPLLDEName$)
WriteByte(0)
EndIf
UseFile(#PBL_File)
Repeat
sLine$ = Trim(ReadString())
If CountString(sLine$, " ") = 0
MessageRequester("Error", "Malformed line. Should be in the form: FunctionName NbParameter", #MB_ICONSTOP | #MB_OK)
ProcedureReturn #False
EndIf
sFunctionName$ = Trim(StringField(sLine$, 1, " "))
nFunctionParam.l = Val(Trim(StringField(sLine$, 2, " ")))
If Left(Trim(StringField(sLine$, 1, " ")), 1) <> ";"
UseFile(#ERUPLLDE_File)
Debug sFunctionName$
WriteString(sFunctionName$)
WriteByte(0)
Debug nFunctionParam
WriteByte(nFunctionParam)
WriteByte(0)
EndIf
UseFile(#PBL_File)
Until Eof(#PBL_File)
CloseFile(#PBL_File)
CloseFile(#ERUPLLDE_File)
MessageRequester("Info", "Fixing finished." + Chr(10) + Chr(10) + "Tried To fix the File: " + Chr(10) + Chr(10) + sDestinationPath$ + sERUPLLDEName$, #MB_OK | #MB_ICONINFORMATION)
ProcedureReturn #True
EndProcedure
Procedure LoadPrefs()
Shared sSourcePath$
Shared sDestinationPath$
If ReadFile(#PREFS_File, ExePath() + "ERUPLLDE_Fixer.prefs")
sSourcePath$ = ReadString()
sDestinationPath$ = ReadString()
CloseFile(#PREFS_File)
EndIf
EndProcedure
Procedure SavePrefs()
Shared sSourcePath$
Shared sDestinationPath$
Debug sSourcePath$
Debug sDestinationPath$
Debug ExePath() + "ERUPLLDE_Fixer.prefs"
CreateFile(#PREFS_File, ExePath() + "ERUPLLDE_Fixer.prefs")
CloseFile(#PREFS_File)
If OpenFile(#PREFS_File, ExePath() + "ERUPLLDE_Fixer.prefs") <> 0
Debug ExePath() + "ERUPLLDE_Fixer.prefs"
Debug sSourcePath$
Debug sDestinationPath$
WriteStringN(sSourcePath$)
WriteStringN(sDestinationPath$)
CloseFile(#PREFS_File)
EndIf
EndProcedure