Thread: New Control Panel Applet

  1. #1
    Registered User
    Join Date
    May 2004
    Posts
    6

    New Control Panel Applet

    Hey there...

    Recently I have been looking into creating new Control Panel applets in C.

    I got this link from Msdn: Msdn Shell Stuff which seemed very helpful and tried to use their sample code. This however did not work...
    I simplified their code to this, which still has a problem:
    Code:
    #include <cpl.h> 
    
    BOOL WINAPI CALLBACK __declspec(dllexport) CPlApplet(HWND hwnd,UINT Msg,LONG lParam1,LONG lParam2) 
    { 
       CPLINFO * cp; 
       switch(Msg) { 
          case CPL_INIT: 
             //no memory to set, so do nothing... 
             return TRUE; 
          case CPL_GETCOUNT: 
             return 1;    //only one subprogram... 
          case CPL_INQUIRE: 
             cp = (CPLINFO*)lParam2; 
             cp->idIcon = IDMAINICON; 
             cp->idName = IDNAME; 
             cp->idInfo = IDDESCR; 
             cp->lData  = 0; 
             return 0; 
          case CPL_DBLCLK: 
             MessageBox(hwnd,"The message was correctly processed?","status",0); 
             break; 
       } 
       return FALSE; 
    }
    The problem is that when called from the Control Panel as it supposed to be, Explorer crashes. hmmm. Don't know why?
    Using Messageboxes, saw that CPL_INIT was called, and that the crash was just after. There were no error logs, and I don't know how to track this down further.

    The dll file generated had CPlApplet as entry-point, as I think it was supposed to...

    Thanks for your time and trouble.

  2. #2
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    CPL_NEWINQUIRE Message

    If the CPlApplet function processes this message successfully, it should return zero.
    Assumably, if you don't handle this message you should return non-zero. If that is the case, the MSDN sample is wrong.

    Then again, with this bit of inspired code, I wouldn't be too surprised.
    Code:
    HWND hwndCPL;      // handle to Control Panel window 
    UINT uMsg;         // message 
    LPARAM lParam1;    // first message parameter 
    LPARAM lParam2;    // second message parameter 
    
    LONG CALLBACK CPlApplet(hwndCPL, uMsg, lParam1, lParam2) 
    { 
        int i; 
        LPCPLINFO lpCPlInfo; 
    ...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. DirectX Control Panel Console
    By Tonto in forum Game Programming
    Replies: 1
    Last Post: 06-12-2007, 11:25 PM
  2. Add your self to the control panel
    By Queatrix in forum Windows Programming
    Replies: 1
    Last Post: 10-03-2006, 03:26 PM
  3. Button handler
    By Nephiroth in forum Windows Programming
    Replies: 8
    Last Post: 03-12-2006, 06:23 AM
  4. Opening Control Panel Items
    By MFC Programmer in forum Windows Programming
    Replies: 0
    Last Post: 06-19-2002, 04:00 PM
  5. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM