wslh Posted November 16, 2010 Share Posted November 16, 2010 Hi, I want to check if Outlook is present, as part of the process I use: $clsid = DllCall ("Ole32.dll","ULONG_PTR", "CLSIDFromProgID", "wstr", "Outlook.Application") but I need to pass an OLESTR instead of an wstr, how can I accomplish that? Also, how do I check if $clsid is null? I use IsPtr function to do that. Is this correct? Thanks, wslh Link to comment Share on other sites More sharing options...
trancexx Posted November 16, 2010 Share Posted November 16, 2010 No, you need to pass LPCOLESTR. That's the same as "wstr". Btw, you are calling it wrong. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
water Posted November 16, 2010 Share Posted November 16, 2010 The Outlook UDF uses ObjCreate to connect to Outlook. So you could write: Local $oOutlook = ObjCreate("Outlook.Application") If @error Or Not IsObj($oOutlook) Then MsgBox(0,"","Error opening Outlook") My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
wslh Posted November 16, 2010 Author Share Posted November 16, 2010 No, you need to pass LPCOLESTR.That's the same as "wstr".Btw, you are calling it wrong.But how I can do that? there is not LPCOLESTR in the help's parameter list.Can you drop the line?Thanks,wslh Link to comment Share on other sites More sharing options...
wslh Posted November 16, 2010 Author Share Posted November 16, 2010 Thanks water but I don't want to create an Outlook instance. Link to comment Share on other sites More sharing options...
trancexx Posted November 16, 2010 Share Posted November 16, 2010 (edited) But how I can do that? there is not LPCOLESTR in the help's parameter list. Can you drop the line? Thanks, wslh Func _WinAPI_CLSIDFromProgID($sProgID) Local $tGUID = DllStructCreate($tagGUID) Local $aCall = DllCall("ole32.dll", "long", "CLSIDFromProgID", "wstr", $sProgID, "ptr", DllStructGetPtr($tGUID)) If @error Or $aCall[0] Then Return SetError(1, 0, 0) Return $tGUID EndFunc Just check if 0 is returned or not. edit: actually don't check 0 (there is a bug in AutoIt with dllstruct type). Check it like this:If IsDllStruct(_WinAPI_CLSIDFromProgID("Outlook.Application")) Then... Edited November 16, 2010 by trancexx ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
water Posted November 16, 2010 Share Posted November 16, 2010 Using the information from MSDN and the AutoIT tool "h2au3" (it converts C-headers to Autoit) I get the following:Func CLSIDFromProgID ($lpszProgID, $lpclsid) Local $aRes = DllCall ($ole32dll, "LONG", "CLSIDFromProgID", _ "PTR", $lpszProgID, _ "PTR", $lpclsid) Return $aRes[0] EndFunc My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
wslh Posted November 16, 2010 Author Share Posted November 16, 2010 Sorry trancexx, It doesn't work for me. $tagGUID must be created before the DLLStructCreate? Thanks, wslh Func _WinAPI_CLSIDFromProgID($sProgID) Local $tGUID = DllStructCreate($tagGUID) Local $aCall = DllCall("ole32.dll", "long", "CLSIDFromProgID", "wstr", $sProgID, "ptr", DllStructGetPtr($tGUID)) If @error Or $aCall[0] Then Return SetError(1, 0, 0) Return $tGUID EndFunc Just check if 0 is returned or not. edit: actually don't check 0 (there is a bug in AutoIt with dllstruct type). Check it like this:If IsDllStruct(_WinAPI_CLSIDFromProgID("Outlook.Application")) Then... Link to comment Share on other sites More sharing options...
trancexx Posted November 16, 2010 Share Posted November 16, 2010 Open freaking help file and type $tagGUID. If for example you would #include <WinApi.au3> (as the name of the function suggest) there would be no issues. Use imagination, not to say head. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
wslh Posted November 16, 2010 Author Share Posted November 16, 2010 Open freaking help file and type $tagGUID.If for example you would #include <WinApi.au3> (as the name of the function suggest) there would be no issues.Use imagination, not to say head.Sorry trancexx, I know that it sounds lazy, but because I am an AutoIt newbie $tagGUID seemed like a local variable to me and I didn't realize it was a global definition.Thank You,wslh 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