开发者

How to make " #using <System.DLL>" work in Qt?

How can I check if a process with a given name ("PowerPNT") is running?

After further web research, I've concluded that there is no Qt function which is able to do it :(, so I had to use a Win32 function, "GetProcessesByName" as described below.

#using <System.dll>
#include <windows.h>
int main()
{
    ...
    if ( System::Diagnostics::Process::GetProcessesByName( "PowerPNT" ).Length > 0 )
    {
        //Do something
    }
    ...
}

This does work for MSVC but unfortunately it doesn't for Qt:

erreur : invalid preprocessing directive #using

开发者_StackOverflowI think that the problem is how to import the "System library" into Qt. I've looked around but no luck :( since I've never dealt with a DLL.

Is this feasible in Qt? If it is, how to fix it?


This is C++/CLI which runs under .NET. You need plain C++ for your Qt project, presumably.


As mentioned, don't try and mix .NET and Qt. Instead use the native Win32 API for this : try the EnumProcesses() function.

Take a look at this example : http://msdn.microsoft.com/en-us/library/ms682623%28v=VS.85%29.aspx

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜