如何在c ++中检查Microsoft Outlook是否已打开? [英] How to check whether Microsoft outlook is opened or not in c++?

查看:135
本文介绍了如何在c ++中检查Microsoft Outlook是否已打开?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我想根据outlook是否打开在我的应用程序中执行特定操作。



任何人都可以告诉我们如何检查"Outlook"是否"是否在c ++中打开。



我尝试了这段代码,但这总是返回false。

 CLSID clsid; 
HRESULT hr = CLSIDFromProgID(_T(" Outlook.Application"),& clsid);
如果(hr!= S_OK)返回false;

IUnknown * pUnknown = NULL;
hr = GetActiveObject(clsid,0,& pUnknown);
return(hr == S_OK);





任何帮助都将不胜感激。



问候,



Siva







0 下来
投票
收藏夹

解决方案

您好
sivavuyyuru,


感谢您在这里发帖。


>>有没有人可以告诉我们如何在c ++中检查是否打开了"Outlook"。


我尝试了这段代码,但这总是返回false。


CLSIDFromProgID方法的第一个参数是指向
ProgID
,而不是进程名称。使用的ProgID条目文件关联位于注册表中的HKEY_CLASSES_ROOT下。前景的ProgID是"Outlook.EXE"。


或者您可以按照以下步骤检查Outlook是否正在运行。 / p>

1.使用每个进程迭代进程ID返回"EnumProcesses"。


2.然后使用"OpenProcess"找到进程的名称。和"GetModuleBaseName"如上面的MSDN链接所示。


3.搜索字符串"Outlook"在上述步骤(步骤3)返回的进程名称中。


4.Call"EnumProcesses"。将返回进程ID列表。


以下是您作为参考的示例代码。


https://msdn.microsoft.com/en-us/library/windows/desktop/ms682623( v = vs.85).aspx


希望这可以帮到你。


最好的问候,


Sera Yu







Hi,

I want to perform a specific action in my application based on whether outlook is opened or not.

Could anyone please let me know how do we check whether "Outlook" is opened or not in c++.

I tried this piece of code but this is always returning false.

	CLSID clsid;
	HRESULT hr = CLSIDFromProgID(_T("Outlook.Application"), &clsid);
	if (hr != S_OK) return false;

	IUnknown *pUnknown = NULL;
	hr = GetActiveObject(clsid, 0, &pUnknown);
	return (hr == S_OK);


Any help would be greatly appreciated.

Regards,

Siva

0down votefavorite

解决方案

Hi sivavuyyuru,

thanks for posting here.

>>Could anyone please let me know how do we check whether "Outlook" is opened or not in c++.

I tried this piece of code but this is always returning false.

The first parameter of CLSIDFromProgID method is a pointer to the ProgID whose CLSID is requested, not the process name. The ProgID entries used for file associations are located under HKEY_CLASSES_ROOT in the registry. The ProgID of the outlook is "Outlook.EXE".

Or you could follow these steps to check whether outlook is running.

1.Iterate through each process using process ID return by "EnumProcesses".

2.Then find the name of process using "OpenProcess" and "GetModuleBaseName" as shown in above MSDN link.

3.Search for the string "Outlook" in the process name returned by above step (step 3).

4.Call "EnumProcesses". Will return the list of process IDs.

Here is a sample code for you as a reference.

https://msdn.microsoft.com/en-us/library/windows/desktop/ms682623(v=vs.85).aspx

Hope this could be help of you.

Best Regards,

Sera Yu


这篇关于如何在c ++中检查Microsoft Outlook是否已打开?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆