Qbasicnews.com

Full Version: advapi32 header
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I've been writing a header for FB for this library and although no errors occur in compilation, the application I wrote for it fails. The EXE crashes and I have no idea why...it's all perfectly legitimate code. I'm using the libadvapi32.a from the latest mingw. Anyone have any ideas?
maybe if you posted the actual code... Wink
From advapi32.bi:
Code:
Declare Function RegOpenKey Lib "advapi32" Alias "RegOpenKeyA" (ByVal hKey As Integer, ByVal lpSubKey As String, phkResult As Integer) As Integer
'more declares here, unneccessary for this example
Const HKEY_CLASSES_ROOT = &H80000000
Const HKEY_CURRENT_USER = &H80000001
Const HKEY_LOCAL_MACHINE = &H80000002
Const HKEY_USERS = &H80000003
Const HKEY_CURRENT_CONFIG = &H80000005
Const HKEY_DYN_DATA = &H80000006
'more stuff follows that's not used in this example
From registry.bas:
Code:
'$include: 'advapi32.bi'
Declare Sub WriteRegistry(ByVal Group As Integer, ByVal Section As String, ByVal Key As String, NewVal As String)

Sub WriteRegistry(ByVal Group As Integer, ByVal Section As String, ByVal Key As String, NewVal As String)
Dim lResult As Integer
Dim lKeyValue As Integer
Dim InLen As Integer
lResult = RegOpenKey(Group, Section, lKeyValue)
InLen = Len(NewVal)
' more code follows, but the error takes place on the RegOpenKey line
The reason I didn't post code before is in case anyone had any ideas as to why this might be happening...perhaps I'm forgetting a detail or two somewhere.
actually, it seems to be crashing on the 'InLen = Len(NewVal)' line at first glance... (uh-oh - fb bug time?)
You can declare byval string arguments to call other C functions, but you can't use them in FB procs, i should add a check for that..


Edit: check added, will be on the next release.. call me a lazy ass, but i had a problem with a byval string argument on the compiler itself.. mm
By removing the ByVals, the program does not crash. However, it also does not function as intended...it runs though...it just...doesn't...function... Sad
Well, I did get one function to work, which is a call to GetUserName. However, the registry read/write functions fail. I don't have a list of return codes handy at the moment and I'm not really tracing them...perhaps I should though...hrm... Big Grin
You can send me the test if you want, with sources.. i can check it using the ollydbg debugger.
Sorry for the delayed reply...if I can't get it working tonight, I'll archive what I've got so far and send it your way.