2009-07-23 5 views
2

私はプログラムでタスクバーにある各プログラムの現在のタスクバーのアイコン(ないシステムトレイ)を取得する方法を探しています。アクセスし、Windowsのタスクバーのアイコン++

結果のすべてがシステムトレイに関連するので、私は、MSDNやGoogleと多くの運を持っていませんでした。

ご意見やご指摘をお寄せください。

EDIT: 私はキーガンヘルナンデスのアイデアを試してみましたが、私は私が何か間違ったことを行っているかもしれないと思います。コードは次のとおりです(C++)。

#include <iostream> 
#include <vector> 
#include <windows.h> 
#include <sstream> 
using namespace std; 
vector<string> xxx; 
bool EnumWindowsProc(HWND hwnd,int ll) 
{ 
    if(ll=0) 
    { 
     //... 
     if(IsWindowVisible(hwnd)==true){ 
     char tyty[129]; 
     GetWindowText(hwnd,tyty,128); 
     stringstream lmlm; 
     lmlm<<tyty; 
     xxx.push_back(lmlm.str()); 
     return TRUE; 
     } 
    } 
} 
int main() 
{ 
    EnumWindows((WNDENUMPROC)EnumWindowsProc,0); 
    vector<string>::iterator it; 
    for(it=xxx.begin();it<xxx.end();it++) 
    {cout<< *it <<endl;} 
    bool empty; 
    cin>>empty; 
} 

答えて

0

コードにいくつかの問題があります。私の修正をご覧ください。あなたのコンパイラで警告を上げて(またはビルドの出力を読む)、警告を出しているはずです(または警告したはずです)!

#include <iostream> 
#include <vector> 
#include <windows.h> 
#include <sstream> 
using namespace std; 
vector<string> xxx; 
// The CALLBACK part is important; it specifies the calling convention. 
// If you get this wrong, the compiler will generate the wrong code and your 
// program will crash. 
// Better yet, use BOOL and LPARAM instead of bool and int. Then you won't 
// have to use a cast when calling EnumWindows. 
BOOL CALLBACK EnumWindowsProc(HWND hwnd,LPARAM ll) 
{ 
    if(ll==0) // I think you meant '==' 
    { 
     //... 
     if(IsWindowVisible(hwnd)==true){ 
     char tyty[129]; 
     GetWindowText(hwnd,tyty,128); 
     stringstream lmlm; 
     lmlm<<tyty; 
     xxx.push_back(lmlm.str()); 
     //return TRUE; What if either if statement fails? You haven't returned a value! 
     } 
    } 
    return TRUE; 
} 
int main() 
{ 
    EnumWindows(EnumWindowsProc,0); 
    vector<string>::iterator it; 
    for(it=xxx.begin();it<xxx.end();it++) 
    {cout<< *it <<endl;} 
    bool empty; 
    cin>>empty; 
} 
+0

また、元のウィンドウのスタイルをチェックするには、ツールバーのウィンドウを除外し、appwindowを含めます – Anders

1

うまくいけば、これはあなたが始めるのに十分です:

WinAPIのは、現在インスタンス化され、各HWNDのためのコールバック関数を呼び出します関数EnumWindowsを持っています。それはフォームのコールバック書き込む使用する:

BOOL CALLBACK EnumWindowsProc(HWND HWND、LPARAM lParamにします)。 APIは、HWNDがある特定のウィンドウを表し、各ウィンドウのためのコールバックを呼び出しますように

その後EnumWindows(EnumWindowsProc、lParamに)を呼び出します。

各ウィンドウはタスクバーに、コールバックが受信する各HWNDに機能IsWindowVisible(HWND)を使用することができ、したがって、可視およびかどうかを決定します。運が良ければ、そのコールバックに渡されたHWNDから必要な情報を得ることができます。

+1

すべてのウィンドウ/プログラムがタスクバーに表示されるわけではありません。 C#では簡単にこれを行うことができます... – RvdK

+0

私はEnumWindowsを使用している場合、多くのナンセンスウィンドウ(スタートメニュー、アプリの一時ウィンドウなど)のリストを提供します。 – jondinham

関連する問題