Logman Posted August 1, 2012 Share Posted August 1, 2012 Zedna, your UDF is really useful. One question... How to get the file version of the included file? I would like to compare the version of SQLite3.dll files (compare the file distributed with application and a dll installed on the client PC). Link to comment Share on other sites More sharing options...
Zedna Posted August 2, 2012 Author Share Posted August 2, 2012 Zedna, your UDF is really useful. One question... How to get the file version of the included file? I would like to compare the version of SQLite3.dll files (compare the file distributed with application and a dll installed on the client PC).I don't know how to do this but fileversion of your resource DLL file is known at compile time so you can check it manually (or by some helper script) before compile time and store this information (as string) in global variable and later at runtime just compare DLL version installed on client PC against this stored global version string. Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Logman Posted August 2, 2012 Share Posted August 2, 2012 It is a pity, but I understand. I wanted to avoid the manual definition of a constant in the script. I prefer the way 'Copy & Play' - all fully automated. Link to comment Share on other sites More sharing options...
Yashied Posted August 2, 2012 Share Posted August 2, 2012 #Include <WinAPIEx.au3> $hDll = _WinAPI_GetModuleHandle('sqlite3.dll') If Not $hDll Then $hDll = _WinAPI_LoadLibrary('sqlite3.dll') EndIf $sPath = _WinAPI_GetModuleFileNameEx(_WinAPI_GetCurrentProcess(), $hDll) $sVer = FileGetVersion($sPath) ConsoleWrite($sVer & @CR) My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
Logman Posted August 2, 2012 Share Posted August 2, 2012 Zedna, I'm sorry, but I have another question about _ResourceSaveToFile function. I'm trying to install a file to a folder with administrator privileges only. Compiled file running as administrator will install fine, but without an administrator nothing happens. The function below returns always the same result. Func installResourceFile($sDestFile, $sResName, $sResType=10, $ResLang=0, $CreatePath=1, $DLL = -1) ; get filesize first _ResourceGet($sResName, $sResType, $ResLang, $DLL) If @error Then Return -1 Local $filesize = @extended If $filesize = 0 Then Return -2 Local $result = _ResourceSaveToFile($sDestFile,$sResName,$sResType,$ResLang,$CreatePath,$DLL) MsgBox(0, '$result', $result) ; <<-- ?? If @error Then MsgBox(0, 'Error', 'Some error') ; <<-- ?? Return -1 EndIf While 1 If FileExists($sDestFile) And FileGetSize($sDestFile) = $filesize Then ExitLoop Sleep(100) WEnd Return 1 EndFunc ; ==>> installResourceFile I do not want to run the application as admin and I'll have to check the user right of each folder before installing each file. Is there the possibility to return different values for successful and unsuccessful _ResourceSaveToFile? #Include <WinAPIEx.au3> $hDll = _WinAPI_GetModuleHandle('sqlite3.dll') If Not $hDll Then $hDll = _WinAPI_LoadLibrary('sqlite3.dll') EndIf $sPath = _WinAPI_GetModuleFileNameEx(_WinAPI_GetCurrentProcess(), $hDll) $sVer = FileGetVersion($sPath) ConsoleWrite($sVer & @CR) Yashied, I meant to get a file version of DLL that is included as resource only: Yashied, I meant to get a file version of DLL that is included as resource only: #... #AutoIt3Wrapper_Res_File_Add=resources\SQLite3.dll, rt_rcdata, SQL_FILE_1 #AutoIt3Wrapper_Res_File_Add=resources\SQLite3_x64.dll, rt_rcdata, SQL_FILE_2 #... Link to comment Share on other sites More sharing options...
Zedna Posted August 3, 2012 Author Share Posted August 3, 2012 (edited) Zedna, I'm sorry, but I have another question about _ResourceSaveToFile function. I'm trying to install a file to a folder with administrator privileges only. Compiled file running as administrator will install fine, but without an administrator nothing happens. The function below returns always the same result. ... Local $result = _ResourceSaveToFile($sDestFile,$sResName,$sResType,$ResLang,$CreatePath,$DLL) MsgBox(0, '$result', $result) ; <<-- ?? If @error Then MsgBox(0, 'Error', 'Some error') ; <<-- ?? Return -1 EndIf ... I do not want to run the application as admin and I'll have to check the user right of each folder before installing each file. Is there the possibility to return different values for successful and unsuccessful _ResourceSaveToFile? Try this: ... Local $result = _ResourceSaveToFile($sDestFile,$sResName,$sResType,$ResLang,$CreatePath,$DLL) If @error Then MsgBox(0, 'Error', 'Some error: ' & @error & @CRLF & 'return value: ' & $result) ; result should be 0 Return -1 Else MsgBox(0, '$result', $result) ; result should be <> 0 EndIf ... You can also use return value which is 0 at error or FileSize when all is OK. EDIT: Your MsgBox immediatelly after calling _ResourceSaveToFile() reset @error to zero. Edited August 3, 2012 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Logman Posted August 5, 2012 Share Posted August 5, 2012 The problem is that _ResourceSaveToFile() return no error when installing to a system folder without authorization.... _ResourceSaveToFile($sDestFile,$sResName,$sResType,$ResLang,$CreatePath,$DLL) If @error Then Return -1 EndIF ...So before installation I have to check with an external function if destination folder is writable. Link to comment Share on other sites More sharing options...
Zedna Posted August 5, 2012 Author Share Posted August 5, 2012 The problem is that _ResourceSaveToFile() return no error when installing to a system folder without authorization. ... _ResourceSaveToFile($sDestFile,$sResName,$sResType,$ResLang,$CreatePath,$DLL) If @error Then Return -1 EndIF ... According to simplified source of _ResourceSaveToFile(): Func _ResourceSaveToFile($FileName, $ResName, $ResType = 10, $ResLang = 0, $CreatePath = 0, $DLL = -1) ; $RT_RCDATA = 10 Local $ResStruct, $ResSize, $FileHandle If $CreatePath Then $CreatePath = 8 ; mode 8 = Create directory structure if it doesn't exist in FileOpen() ; standard way $ResStruct = _ResourceGetAsBytes($ResName, $ResType, $ResLang, $DLL) If @error Then Return SetError(1, 0, 0) $ResSize = DllStructGetSize($ResStruct) $FileHandle = FileOpen($FileName, 2+16+$CreatePath) If @error Then Return SetError(2, 0, 0) FileWrite($FileHandle, DllStructGetData($ResStruct, 1)) If @error Then Return SetError(3, 0, 0) FileClose($FileHandle) If @error Then Return SetError(4, 0, 0) Return $ResSize EndFunc it seems there is problem/bug in FileOpen() which probably don't return @error So this problem probably is not related to resources/my UDF but directly to AutoIt. In _ResourceSaveToFile() there are correctly checked/handled all @error states after FileOpen/FileWrite/FileClose. Try small testing script to check if my doubt is correct: $FileHandle = FileOpen('c:\your system path', 2+16+$CreatePath) If @error Then ... Also problem may be in using parameter 8 (CreatePath) in FileOpen for system directory, try it without this parameter. Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Logman Posted August 5, 2012 Share Posted August 5, 2012 (edited) Yes, you're right. The problem is in the FileOpen() function, which returns no error. #include <File.au3> Local $sTmpFile = _TempFile(@SystemDir) $hFile = FileOpen($sTmpFile, 2 + 8 + 16) If @error Then MsgBox(0, "Error handle", "An error while opening file.") ; <<-- this message does not show Exit EndIf If $hFile = -1 Then MsgBox(0, "Error", "Unable to open file.") ; <<-- this message always appears Exit EndIf FileClose($sTmpFile) What about change the causing line in _ResourceSaveToFile(): ; ... $FileHandle = FileOpen($FileName, 2+16+$CreatePath) If @error Then Return SetError(2, 0, 0) ; ... to ; ... $FileHandle = FileOpen($FileName, 2+16+$CreatePath) If $FileHandle = -1 Then Return SetError(2, 0, 0) ; ... And maybe the line with FileWrite() function... Edited August 5, 2012 by Logman Link to comment Share on other sites More sharing options...
Zedna Posted August 5, 2012 Author Share Posted August 5, 2012 What about change the causing line in _ResourceSaveToFile(): ; ... $FileHandle = FileOpen($FileName, 2+16+$CreatePath) If @error Then Return SetError(2, 0, 0) ; ... to ; ... $FileHandle = FileOpen($FileName, 2+16+$CreatePath) If $FileHandle = -1 Then Return SetError(2, 0, 0) ; ... Yes. You are right. Now I'm looking into AutoIt's helpfile and there is really no @error set when error occurs at FileOpen() it just returns -1 as return value. So my Func _ResourceSaveToFile() must be fixed this way: Func _ResourceSaveToFile($FileName, $ResName, $ResType = 10, $ResLang = 0, $CreatePath = 0, $DLL = -1) ; $RT_RCDATA = 10 Local $ResStruct, $ResSize, $FileHandle, $ret If $CreatePath Then $CreatePath = 8 ; mode 8 = Create directory structure if it doesn't exist in FileOpen() If $ResType = $RT_BITMAP Then ; workaround: for RT_BITMAP _ResourceGetAsBytes() doesn't work so use _ResourceGetAsImage() $hImage = _ResourceGetAsImage($ResName, $ResType) If @error Then Return SetError(10, 0, 0) ; create filepath if doesn't exist $FileHandle = FileOpen($FileName, 2+16+$CreatePath) If $FileHandle = -1 Then Return SetError(11, 0, 0) $ret = FileClose($FileHandle) If $ret = 0 Then Return SetError(12, 0, 0) _GDIPlus_ImageSaveToFile($hImage, $FileName) _GDIPlus_ImageDispose($hImage) $ResSize = FileGetSize($FileName) Else ; standard way $ResStruct = _ResourceGetAsBytes($ResName, $ResType, $ResLang, $DLL) If @error Then Return SetError(1, 0, 0) $ResSize = DllStructGetSize($ResStruct) $FileHandle = FileOpen($FileName, 2+16+$CreatePath) If $FileHandle = -1 Then Return SetError(2, 0, 0) $ret = FileWrite($FileHandle, DllStructGetData($ResStruct, 1)) If $ret = 0 Then Return SetError(3, 0, 0) $ret = FileClose($FileHandle) If $ret = 0 Then Return SetError(4, 0, 0) EndIf Return $ResSize EndFunc Thanks for finding bug in my Resources UDF :-) Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Emiel Wieldraaijer Posted August 11, 2012 Share Posted August 11, 2012 @Zedna, Are you going to update the first post ? Thnx Emiel Best regards,Emiel Wieldraaijer Link to comment Share on other sites More sharing options...
Zedna Posted August 13, 2012 Author Share Posted August 13, 2012 (edited) Are you going to update the first post ?Currently I have no time. Later ... Edited August 13, 2012 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Zedna Posted August 24, 2012 Author Share Posted August 24, 2012 Today I discovered problem/bug in my Resources UDF (in one of my projects using it). In application with more than one GUI I used _ResourceSetImageToCtrl($button_xx, "BMP_XX", $RT_BITMAP) for setting bitmap image to this button. In compiled EXE image wasn't shown and problem was in resources.au3 in Func _SetBitmapToCtrl($CtrlId, $hBitmap) Code $CtrlId = _WinAPI_GetDlgCtrlID($hWnd) ; support for $CtrlId = -1 returned strange data and later _WinAPI_GetClassName($CtrlId) returned "IME" instead of expected "Button" ClassName. I don't know exact reason why this problem occured but quick hack/workaround is to use in resources.au3 in Func _SetBitmapToCtrl($CtrlId, $hBitmap) instead of original $CtrlId = _WinAPI_GetDlgCtrlID($hWnd) ; support for $CtrlId = -1 If @error Then Return SetError(2, 0, 0) this fixed code If $CtrlId = -1 Then ; workaround here <--- $CtrlId = _WinAPI_GetDlgCtrlID($hWnd) ; support for $CtrlId = -1 If @error Then Return SetError(2, 0, 0) EndIf So if I don't use -1 as Control Id then this problem will not occur. Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
AZJIO Posted September 1, 2012 Share Posted September 1, 2012 (edited) _ResourceGetAsBitmapReturn _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)_ResourcePlaySoundIf $DLL <> -1 The _WinAPI_FreeLibrary($hInstance) If @error Then Return SetError(2, 0, 0) EndIfCan't make the examples without compiling - _ResourceSaveToFile, _ResourceGetAsString, _ResourceGetAsStringW Edited September 1, 2012 by AZJIO My other projects or all Link to comment Share on other sites More sharing options...
DOTCOMmunications Posted December 5, 2012 Share Posted December 5, 2012 Hi all I tried the examples today and finally got it working after looking back in this thread. However when i compile/build our program i use the command line to call the wrapper program so i am wondering what the difference is between using Compile (which doesnt seem to work from right click context menu) and Build (from Scite) and how that would effect my command line call to AutoIT Wrapper as i would really like to use this UDF? Link to comment Share on other sites More sharing options...
LuisMartins Posted December 16, 2012 Share Posted December 16, 2012 Got it to work perfectly with my JPEG, thanks. Does this also works with embedding .DLL into the .EXE? If yes could you give me some example? Thanks in advance! Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 16, 2012 Moderators Share Posted December 16, 2012 DOTCOMmunications,Zedna has not been around for a while so I hope you do not mind me replying. Within SciTE the 2 options work like this - assuming you are using the full SciTE4AutoIt3 install:- Compile - brings up a dialog where you can set various compile options.- Build - compiles using the existing AutoIt3Wrapper directives in the script.M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
PerfyNormal Posted December 31, 2012 Share Posted December 31, 2012 Hello, I've got a question regarding tray icons. There have been some examples in here regarding it but nothing only around the question. I've searched but either not understood or found anything definitive, thus I've decided to post. I'd like to have embedded icons in my compiled executable, that I can then call in my script to change the tray icon between Do not want to use a temporary folder and do not use any GUI, only a tray icon. How do I add the icons into my file for tray use and how do I call them without saving them temporary on the computer? Link to comment Share on other sites More sharing options...
guinness Posted December 31, 2012 Share Posted December 31, 2012 Look at this >> You will find plenty of examples around the Forum. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
jb11 Posted April 3, 2013 Share Posted April 3, 2013 I have been searching but was unable to find anything specific to this situation. Basically I want to add an icon file to my script and then use the icon resource in FileCreateShortcut() when I run the script. Is this possible? 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