Danyfirex Posted May 1, 2014 Share Posted May 1, 2014 Hi mate. I've been playing with ObjCreateInterface. And I can get some CLSID from IID. (I don't understand how to get it) I look into msdn and find nothing. for example I see this interface http://msdn.microsoft.com/en-us/library/windows/desktop/ms687223(v=vs.85).aspx#methods look at the end and see IID IID_IPersistFile is defined as 0000010b-0000-0000-C000-000000000046 But I can't find the CLSID. The simple question is: ¿how can I get the CLSID from IID? Saludos Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
Solution LarsJ Posted May 2, 2014 Solution Share Posted May 2, 2014 (edited) The simple answer is: You don't get a CLSID from a IID.A CLSID is a GUID identifying a COM class.An IID is a GUID identifying a COM interface.A COM class (or object) typically implements several COM interfaces. When using a COM class you must both specify an identifier for the COM class, and an identifier for the actual COM interface.The most common way to create a COM interface, is to use QueryInterface to get a pointer for the interface object, and then create the interface with ObjCreateInterface.Here's a random example:$oIShellView.QueryInterface( $tRIID_IFolderView, $pIFolderView ) $oIFolderView = ObjCreateInterface( $pIFolderView, $sIID_IFolderView, $dtag_IFolderView )I think IPersistFile is mostly used in connection with other interfaces, and it would probably be created with QueryInterface. Edited May 2, 2014 by LarsJ trancexx, KLM and Danyfirex 3 Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
Danyfirex Posted May 2, 2014 Author Share Posted May 2, 2014 (edited) Thank you for your answer I did not got how to implemente/create IPersistFile. saludos Edit: I got it. I did not read well. saludos Edited May 2, 2014 by Danyfirex Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
LarsJ Posted May 2, 2014 Share Posted May 2, 2014 This is an example with the Shell Link object: expandcollapse popup#include <WinAPI.au3> Global Const $CLSID_ShellLink = "{00021401-0000-0000-C000-000000000046}" Global Const $sIID_IShellLinkW = "{000214F9-0000-0000-C000-000000000046}" Global Const $dtag_IShellLinkW = _ "GetPath hresult();" & _ "GetIDList hresult();" & _ "SetIDList hresult();" & _ "GetDescription hresult();" & _ "SetDescription hresult();" & _ "GetWorkingDirectory hresult();" & _ "SetWorkingDirectory hresult();" & _ "GetArguments hresult();" & _ "SetArguments hresult();" & _ "GetHotkey hresult();" & _ "SetHotkey hresult();" & _ "GetShowCmd hresult();" & _ "SetShowCmd hresult();" & _ "GetIconLocation hresult();" & _ "SetIconLocation hresult();" & _ "SetRelativePath hresult();" & _ "Resolve hresult();" & _ "SetPath hresult();" Global Const $dtag_IPersist = _ "GetClassID hresult();" Global Const $sIID_IPersistFile = "{0000010b-0000-0000-C000-000000000046}" Global Const $tRIID_IPersistFile = _WinAPI_GUIDFromString( $sIID_IPersistFile ) Global Const $dtag_IPersistFile = $dtag_IPersist & _ ; Inherits from IPersist "IsDirty hresult();" & _ "Load hresult();" & _ "Save hresult();" & _ "SaveCompleted hresult();" & _ "GetCurFile hresult();" Opt( "MustDeclareVars", 1 ) MainFunc() Func MainFunc() Local $oIShellLinkW = ObjCreateInterface( $CLSID_ShellLink , $sIID_IShellLinkW, $dtag_IShellLinkW ) If Not IsObj( $oIShellLinkW ) Then Return ConsoleWrite( "$oIShellLinkW ERR" & @CRLF ) ConsoleWrite( "$oIShellLinkW OK" & @CRLF ) Local $pIPersistFile, $oIPersistFile $oIShellLinkW.QueryInterface( $tRIID_IPersistFile, $pIPersistFile ) $oIPersistFile = ObjCreateInterface( $pIPersistFile, $sIID_IPersistFile, $dtag_IPersistFile ) If Not IsObj( $oIPersistFile ) Then Return ConsoleWrite( "$oIPersistFile ERR" & @CRLF ) ConsoleWrite( "$oIPersistFile OK" & @CRLF ) EndFuncAs you can see, the interface description strings are incomplete. Danyfirex 1 Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
Danyfirex Posted May 2, 2014 Author Share Posted May 2, 2014 yes I see. I made mine one already (I should change some parameters I made it for testing.) local $stagIShellLink="getpath hresult(long;long;long;long); " & _ "getidlist hresult(long); " & _ "setidlist hresult(long); " & _ "getdescription hresult(long;long); " & _ "setdescription hresult(wstr); " & _ "getworkingdirectory hresult(long;long); " & _ "setworkingdirectory hresult(long); " & _ "getarguments hresult(long;long); " & _ "setarguments hresult(ptr); " & _ "gethotkey hresult(long); " & _ "sethotkey hresult(word); " & _ "getshowcmd hresult(long); " & _ "setshowcmd hresult(int); " & _ "geticonlocation hresult(long;long;long); " & _ "seticonlocation hresult(wstr;int); " & _ "setrelativepath hresult(long;long); " & _ "resolve hresult(long;long); " & _ "setpath hresult(wstr)" Local $stagIPersistFile="GetClassID hresult(long); IsDirty hresult(); Load hresult(long;long); Save hresult(wstr;bool); SaveCompleted hresult(long); GetCurFile hresult(long)" You really Helped me a lot. thank you very much LarsJ saludos Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
LarsJ Posted May 2, 2014 Share Posted May 2, 2014 It was a pleasure. Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
trancexx Posted May 2, 2014 Share Posted May 2, 2014 You actually don't need to call QueryInterface by yourself because ObjCreateInterface will do that for you by definition. So, just call ObjCreateInterface for $sIID_IPersistFile on ShellLink object. To furher reduce the code, it should be obvious after that being said, that you can simply call ObjCreateInterface with $CLSID_ShellLink as CLSID, $sIID_IPersistFile as IID and $tagIPersistFile interface description to get (wanted) IPersistFile object. Danyfirex and LarsJ 2 ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
LarsJ Posted May 3, 2014 Share Posted May 3, 2014 You are right. This is much, much better:Global Const $CLSID_ShellLink = "{00021401-0000-0000-C000-000000000046}" Global Const $dtag_IPersist = _ "GetClassID hresult();" Global Const $sIID_IPersistFile = "{0000010b-0000-0000-C000-000000000046}" Global Const $dtag_IPersistFile = $dtag_IPersist & _ ; Inherits from IPersist "IsDirty hresult();" & _ "Load hresult();" & _ "Save hresult();" & _ "SaveCompleted hresult();" & _ "GetCurFile hresult();" Opt( "MustDeclareVars", 1 ) MainFunc() Func MainFunc() Local $oIPersistFile = ObjCreateInterface( $CLSID_ShellLink, $sIID_IPersistFile, $dtag_IPersistFile ) If Not IsObj( $oIPersistFile ) Then Return ConsoleWrite( "$oIPersistFile ERR" & @CRLF ) ConsoleWrite( "$oIPersistFile OK" & @CRLF ) EndFunc Danyfirex 1 Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
mLipok Posted May 5, 2014 Share Posted May 5, 2014 Very interesting topic. Thanks to all participating in them Cheers mLipok Danyfirex 1 Signature beginning:* Please remember: "AutoIt"..... * Wondering who uses AutoIt and what it can be used for ? * Forum Rules ** ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 * My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related: * How to use IE.au3 UDF with AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24 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