wslh Posted November 16, 2010 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
trancexx Posted November 16, 2010 Posted November 16, 2010 No, you need to pass LPCOLESTR. That's the same as "wstr". Btw, you are calling it wrong. ♡♡♡ . eMyvnE
water Posted November 16, 2010 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 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
wslh Posted November 16, 2010 Author 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
wslh Posted November 16, 2010 Author Posted November 16, 2010 Thanks water but I don't want to create an Outlook instance.
trancexx Posted November 16, 2010 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
water Posted November 16, 2010 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 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
wslh Posted November 16, 2010 Author 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...
trancexx Posted November 16, 2010 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
wslh Posted November 16, 2010 Author 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
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