xcal Posted August 23, 2006 Share Posted August 23, 2006 Ok, I'm not a programmer/coder, so no laughing. I'm trying to call the "LSGetVariableEx" function in the lsapi.dll for Litestep. The example use of the function is:BOOL LSGetVariableEx( LPCSTR pszKeyName, LPSTR pszBuffer, UINT cbBuffer );The variable I'm trying to get is "ConfigDir." The expected return is the path to the config directory, something like "c:\litestep\themes\themename\config."I've tried tons of different things, but I'm confused about what to do for the "types" in the DLLCall, and I'm sure I'm messing up the DllStructCreate. This is the last thing I tried:$buffer = DllStructCreate("byte") $error = DllCall("c:\litestep\lsapi.dll", "none", "LSGetVariableEx", _ "char", "ConfigDir", "char", $buffer, "ptr", DllStructGetPtr($buffer)) MsgBox(0, "", "Error: " & $error & @CRLF & _ "From Buffer: " & DllStructGetData($buffer, 1))Both values in my msgbox are zero with the above.If anyone could give me suggestions to try, it'd be appreciated.TIA How To Ask Questions The Smart Way Link to comment Share on other sites More sharing options...
Zedna Posted August 23, 2006 Share Posted August 23, 2006 See this:DllCall, Syntax notes and API list And your code should be something like this:(There is also robust error checking for better testing)$return = DllCall("c:\litestep\lsapi.dll", "int", "LSGetVariableEx", _ "str", "ConfigDir", "str", "", "int", 255) If @error Then MsgBox(0, "", "Error: " & @error & @CRLF & _ "Error description: " & _GetLastErrorMessage()) Else MsgBox(0, "", "OK" & @CRLF & _ "From Buffer: " & $return[2]) EndIf Func _GetLastErrorMessage($DisplayMsgBox="") Local $ret,$s Local $p = DllStructCreate("char[4096]") Local Const $FORMAT_MESSAGE_FROM_SYSTEM = 0x00001000 If @error Then Return "" $ret = DllCall("Kernel32.dll","int","GetLastError") $ret = DllCall("kernel32.dll","int","FormatMessage",_ "int",$FORMAT_MESSAGE_FROM_SYSTEM,_ "ptr",0,_ "int",$ret[0],_ "int",0,_ "ptr",DllStructGetPtr($p),_ "int",4096,_ "ptr",0) $s = DllStructGetData($p,1) $p = 0 If $DisplayMsgBox <> "" Then MsgBox(0,"_GetLastErrorMessage",$DisplayMsgBox & @CRLF & $s) return $s EndFunc Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
xcal Posted August 24, 2006 Author Share Posted August 24, 2006 (edited) Great link, thank you. Unfortunately, the solution you provided didn't work for me. I'll keep playing with it. There was no error, but $return[2] was empty. Edited August 24, 2006 by xcal How To Ask Questions The Smart Way Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now