archrival Posted July 31, 2010 Share Posted July 31, 2010 I'm trying to implement MsiOpenDatabaseW from msi.dll. I'm not getting a handle that I would expect. The 2nd parameter, $szPersist, is usually used as an IntPtr in other implementations. Depending on the values I pass I receive an 87 (ERROR_INVALID_PARAMETER), 110 (ERROR_OPEN_FAILED) or 1631 (ERROR_CREATE_FAILED). I would expect this line to work: Global Const $MSIDBOPEN_READONLY = 0 $phDatabase = _MsiOpenDatabase("c:\users\archrival\desktop\xmlnotepad.msi", $MSIDBOPEN_READONLY)What actually happens is:$uRet[0] = 0 $uRet[1] = c:\users\archrival\desktop\xmlnotepad.msi $uRet[2] = 0 $uRet[3] = 0x00000001Any thoughts?Func _MsiOpenDatabase($szDatabasePath, $szPersist) Local $error = 0 Local $extended Local $phDatabase Local $uRet = DllCall($msidll, "UINT", "MsiOpenDatabaseW", "wstr", $szDatabasePath, "wstr", $szPersist, "handle*", $phDatabase) If @error Then $error = @error Else _ArrayDisplay($uRet) If IsArray($uRet) And UBound(4) Then $extended = $uRet[0] $phDatabase = $uRet[3] EndIf EndIf Return SetError($error, $extended, $phDatabase) EndFunc Link to comment Share on other sites More sharing options...
smashly Posted July 31, 2010 Share Posted July 31, 2010 (edited) Hi, Maybe try DllCall($msidll, "int", "MsiOpenDatabaseW", "wstr", $szDatabasePath, "int", $szPersist, "handle*", $phDatabase) I don't get an error and I get a 0x00000001 for the $phDatabase return trying it this way when using $MSIDBOPEN_READONLY (0) value for $szPersist param. Edited July 31, 2010 by smashly Link to comment Share on other sites More sharing options...
archrival Posted August 1, 2010 Author Share Posted August 1, 2010 I forgot mention that I've also tried an int as well as a pointer to a struct containing an int_ptr. The int doesn't return an error but it also doesn't seem to provide a valid handle. Link to comment Share on other sites More sharing options...
archrival Posted August 2, 2010 Author Share Posted August 2, 2010 I forgot mention that I've also tried an int as well as a pointer to a struct containing an int_ptr. The int doesn't return an error but it also doesn't seem to provide a valid handle.Perhaps I should have actually tried the returned handle, it works. Oops... I didn't expect 0x00000001 to be valid. 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