Homes32 Posted March 23, 2011 Share Posted March 23, 2011 (edited) hello all,I'm working on trying to get Attributes from a .wim file and have hit a wall.calling the WIMGetAttributes function from wimgapi.dll always returns false for me and GetLastError() returns 87 ERROR_INVALID_PARAMETERas far as I can tell I have all the parameters correct. and I can confirm that I get the correct handle for $hWim and that the struct is created successfully with a size of: 552 I've been looking at this for so long its hard for me to tell if I have something screwed up. has anybody had success calling this function with autoit?please let me know if there is any information I forgot to give.thanks.Homes32Func _WIM_GetImageAttributes($hWim) Local $aReturn[2] ; array to hold the return data Local $hWimInfo = DllStructCreate($tagWIM_INFO) if @error Then MsgBox(0,"","Error in DllStructCreate: " & @error); $aReturn[0] = DllCall($ghwimgapi, "int", "WIMGetAttributes", _ "ptr", $hWim, _ "ptr", DllStructGetPtr($hWimInfo), _ "int", DllStructGetSize($hWimInfo)) If @error Then Return SetError(@error, @extended, $aReturn) ;$aReturn[0] = DllCall return value Return SetError(@error, _WinAPI_GetLastError(), $aReturn[0]) EndFunc ;==>_WIM_GetAttributes Global Const $tagWIM_INFO = "wchar WimPath[256];byte Guid[16];dword ImageCount;dword CompressionType;ushort PartNumber;" & _ "ushort TotalParts;dword BootIndex;dword WimAttributes;dword WimFlagsAndAttr"[/autoit]function prototype and struct definitionBOOL WINAPI WIMGetAttributes( IN HANDLE hWim, OUT LPWIM_INFO lpWimInfo, IN DWORD cbWimInfo ); typedef struct _WIM_INFO { WCHAR WimPath[MAX_PATH]; GUID Guid; DWORD ImageCount; DWORD CompressionType; USHORT PartNumber; USHORT TotalParts; DWORD BootIndex; DWORD WimAttributes; } WIM_INFO, *PWIM_INFO, *LPWIM_INFO; Edited March 23, 2011 by Homes32 Link to comment Share on other sites More sharing options...
JohnOne Posted March 23, 2011 Share Posted March 23, 2011 I'm far from dllcall expert, but some things look wrong here, comments. Func _WIM_GetImageAttributes($hWim) Local $aReturn[2] ; array to hold the return data Local $hWimInfo = DllStructCreate($tagWIM_INFO) if @error Then MsgBox(0,"","Error in DllStructCreate: " & @error); $aReturn[0] = DllCall($ghwimgapi, "int", "WIMGetAttributes", _ "ptr", $hWim, _ "ptr", DllStructGetPtr($hWimInfo), _ "int", DllStructGetSize($hWimInfo)) If @error Then Return SetError(@error, @extended, $aReturn);<---- not certain you can return and array of array from seterror ;$aReturn[0] = DllCall return value <--- $aReturn[0] will hold another array, if you look at helpfile dllcall returns an array. Return SetError(@error, _WinAPI_GetLastError(), $aReturn[0]) EndFunc ;==>_WIM_GetAttributes Global Const $tagWIM_INFO = "wchar WimPath[256];byte Guid[16];dword ImageCount;dword CompressionType;ushort PartNumber;" & _ "ushort TotalParts;dword BootIndex;dword WimAttributes;dword WimFlagsAndAttr" Func _WIM_GetImageAttributes($hWim) Local $aReturn ; array to hold the return data Local $hWimInfo = DllStructCreate($tagWIM_INFO) if @error Then MsgBox(0,"","Error in DllStructCreate: " & @error); $aReturn = DllCall($ghwimgapi, "int", "WIMGetAttributes", _ "ptr", $hWim, _ "ptr", DllStructGetPtr($hWimInfo), _ "int", DllStructGetSize($hWimInfo)) If @error Then Return SetError(@error, @extended, $aReturn) Return SetError(@error, _WinAPI_GetLastError(), $aReturn[0]) ; might now hold your return value EndFunc ;==>_WIM_GetAttributes Global Const $tagWIM_INFO = "wchar WimPath[256];byte Guid[16];dword ImageCount;dword CompressionType;ushort PartNumber;" & _ "ushort TotalParts;dword BootIndex;dword WimAttributes;dword WimFlagsAndAttr" AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
JohnOne Posted March 23, 2011 Share Posted March 23, 2011 (edited) Sorry, you say you have error with param How about $aReturn[0] = DllCall($ghwimgapi, "int", "WIMGetAttributes", _ "HWND", $hWim, _ "ptr", DllStructGetPtr($hWimInfo), _ "DWORD", DllStructGetSize($hWimInfo)) Edit: Maybe change int return type to BOOLEAN or BYTE Edited March 23, 2011 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
jaberwacky Posted March 23, 2011 Share Posted March 23, 2011 Try this: Global Const $tagWIM_INFO = "wchar WimPath[256];byte Guid[16];dword ImageCount;dword CompressionType;ushort PartNumber;ushort TotalParts;dword BootIndex;dword WimAttributes;dword WimFlagsAndAttr" Func _WIM_GetImageAttributes( $hWim ) Local $hWimInfo = DllStructCreate( $tagWIM_INFO ) If @error Then MsgBox( 0 , "" , "Error in DllStructCreate: " & @error ) EndIf Local $aReturn = DllCall( $ghwimgapi, "bool", "WIMGetAttributes", _ "handle" , $hWim, _ "ptr" , DllStructGetPtr( $hWimInfo), _ "dword" , DllStructGetSize( $hWimInfo ) ) If @error Then Return SetError( @error , @extended , $aReturn ) EndIf Return SetError( @error , _WinAPI_GetLastError() , $aReturn[0] ) EndFunc Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
Homes32 Posted March 23, 2011 Author Share Posted March 23, 2011 (edited) thanks for the replys. I took out the array stuff but that and changing the data type makes no difference. (I tried before posting and tried your examples again just to be sure.) any other thoughts? Func _WIM_GetImageAttributes($hWim) Local $pWimInfo = DllStructCreate($tagWIM_INFO) if @error Then MsgBox(0,"","Error in DllStructCreate: " & @error); $aReturn = DllCall($ghwimgapi, "bool", "WIMGetAttributes", _ "handle", $hWim, _ "ptr", DllStructGetPtr($pWimInfo), _ "dword", DllStructGetSize($pWimInfo)) If @error Then Return SetError(@error, @extended, $aReturn) Return SetError(@error, _WinAPI_GetLastError(), $aReturn[0]) EndFunc ;==>_WIM_GetAttributes Edited March 23, 2011 by Homes32 Link to comment Share on other sites More sharing options...
trancexx Posted March 23, 2011 Share Posted March 23, 2011 (edited) MAX_PATH is 260. edit: That means you are not providing enough free writing space and that's why it's failing Edited March 23, 2011 by trancexx ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Homes32 Posted March 23, 2011 Author Share Posted March 23, 2011 MAX_PATH is 260.edit:That means you are not providing enough free writing space and that's why it's failingthat was my problem! thanks for pointing it out! Cheers!Homes32 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