Menu

#3 Offline-detection if in Tray

All_versions
open-accepted
edk Issues (5)
4
2002-05-28
2002-05-22
Anonymous
No

If Edk is in tray ServSpy always tells edk is offline

Discussion

  • Esben Jensen

    Esben Jensen - 2002-05-22

    Logged In: YES
    user_id=544193

    I already added the fix to this as an upcoming feature. :)

     
  • Esben Jensen

    Esben Jensen - 2002-05-22
    • labels: --> edk Issues
    • priority: 5 --> 4
    • assigned_to: nobody --> noja
    • status: open --> open-accepted
     
  • Esben Jensen

    Esben Jensen - 2002-05-28
    • milestone: 206754 --> All_versions
     
  • Bernd Hesse

    Bernd Hesse - 2002-07-06

    Logged In: YES
    user_id=173654

    I tested a little bit around and wrote a function to Get
    eDonkey out of the tray and which returns the current window
    handle of the eDonkey window - Maybe this code is
    interesting for you:

    HWND GetDonkeyOutOfTray()
    {
    HANDLE fHandle;
    HKEY aKey;
    char DonkeyPath[MAX_PATH];
    char *dk_path;
    DWORD DataSize;
    int i;
    HWND DonkeyWindow;
    char wintitle[500];

    // Find eDonkey-Directory:
        if \(RegOpenKeyEx
    

    (HKEY_CLASSES_ROOT,"ed2k\\DefaultIcon",NULL,KEY_RE
    AD,&aKey)!=ERROR_SUCCESS)
    {
    return (HWND)-1;
    }
    DataSize=MAX_PATH;
    if (RegQueryValueEx
    (aKey,NULL,NULL,NULL,(LPBYTE)DonkeyPath,&DataSize)!
    =ERROR_SUCCESS)
    {
    RegCloseKey(aKey);
    return (HWND)-1;
    }
    RegCloseKey(aKey);

    // Kill quote-marks:
        if \(DonkeyPath\[0\]=='"'\)
        \{
            dk\_path=&DonkeyPath\[1\];
            i=strlen\(dk\_path\);
            dk\_path\[i-1\]='\0';
        \}
        else
        \{
            dk\_path=DonkeyPath;
        \}
    
    // try to get write acces to gdonkey.exe
    // if you can write, eDonkey is running:
        fHandle=CreateFile
    

    (dk_path,GENERIC_WRITE|GENERIC_READ,NULL,NULL,OP
    EN_EXISTING,NULL,NULL);
    if (fHandle!=INVALID_HANDLE_VALUE)
    {
    // eDonkey is not running!
    CloseHandle(fHandle);
    return (HWND)-2;
    }

    // Now just run gdonkey.exe and the currently
    

    running
    // eDonkey-app will come out of his little icon ;-)
    ShellExecute
    (NULL,"open",dk_path,NULL,NULL,SW_SHOWNORMAL);

    // Try to find the window now:
        DonkeyWindow=GetForegroundWindow
    

    ();
    SendMessage
    (DonkeyWindow,WM_GETTEXT,(WPARAM)450,(LPARAM)
    wintitle);
    wintitle[12]='\0';

        while \(strcmp\(wintitle,"eDonkey2000 "\)\!
    

    =0)
    {
    DonkeyWindow=GetWindow
    (DonkeyWindow,GW_HWNDNEXT);
    if (DonkeyWindow==NULL)
    {

    DonkeyWindow=GetForegroundWindow\(\);
            \}
            SendMessage
    

    (DonkeyWindow,WM_GETTEXT,(WPARAM)450,(LPARAM)
    wintitle);
    wintitle[12]='\0';
    }

    return DonkeyWindow;
    

    }

     
  • Esben Jensen

    Esben Jensen - 2002-07-07

    Logged In: YES
    user_id=544193

    Yes that will probably work. I haven't thought about running
    gdonkey.exe in order to get it out of tray.

    I don't really understand why checking for write access to gdonkey.exe
    should ensure a running instance of Edonkey. Could you enlighten me
    on this? :)

    The only problem is that I would consider it a little rude for an app to
    pull another app out of the tray without putting it back, but I could of
    course include the feature as yet another option until a better solution is
    found.

    Anyway thanks a lot for your idea.

     
  • Bernd Hesse

    Bernd Hesse - 2002-07-07

    Logged In: YES
    user_id=173654

    I check for write access, because i did not want to run
    eDonkey if it is not running, and i don't know another method
    how to detect if eDonkey is running, if it is trayed ;-)

    If you know, eDonkey was in Tray before you opened it, it is
    easy to send eDonkey back to tray:

    SendMessage(donkeyWnd,WM_CLOSE,0,0);

     
  • Esben Jensen

    Esben Jensen - 2002-07-07

    Logged In: YES
    user_id=544193

    >If you know, eDonkey was in Tray before you opened it, it is
    >easy to send eDonkey back to tray:
    >SendMessage(donkeyWnd,WM_CLOSE,0,0);

    Of course - if edonkey was in tray, closing the window should be safe,
    because the 'send to tray' option must have ben set.

    Now it does look like a working solution. I'll probably implement this.
    Thanks a lot for your input. :)

     

Log in to post a comment.

MongoDB Logo MongoDB