PDA

Click to See Complete Forum and Search --> : Control Panel Application


Microbasic
Aug 2nd, 2001, 10:03 AM
I'm having a little problem with this code;

#include <windows.h>
#include <cpl.h>
#include "resource.h"
//#include "CPLhhdr.h"

HINSTANCE hinst = NULL;

int WINAPI DllMain(HINSTANCE hinst, DWORD Reason, LPVOID)
{ return 1; }

LONG CALLBACK CPlApplet(HWND hwndCPL, UINT uMsg, LPARAM lParam1, LPARAM lParam2)
{
int i;
LPCPLINFO lpCPlInfo;

i = (int) lParam1;

switch (uMsg) {
case CPL_INIT: // first message, sent once
hinst = GetModuleHandle("test.cpl");
return TRUE;

case CPL_GETCOUNT: // second message, sent once
return 1;
break;

case CPL_INQUIRE: // third message, sent once per application
lpCPlInfo = (LPCPLINFO) lParam2;
lpCPlInfo->lData = 0;
lpCPlInfo->idIcon = IDI_PC;
lpCPlInfo->idName = IDS_NAME;
lpCPlInfo->idInfo = IDS_DESC;
break;

case CPL_DBLCLK: // application icon double-clicked
DialogBox(hinst, MAKEINTRESOURCE(IDD_DIALOG1), hwndCPL, NULL);
break;

case CPL_STOP: // sent once per application before CPL_EXIT
break;

case CPL_EXIT: // sent once before FreeLibrary is called
break;

default:
break;
}
return 0;
}


It's supposed to be for a control panel application file, but when compiled, it gives me this error:

LINK : warning LNK4089: all references to "USER32.dll" discarded by /OPT:REF

And Control Panel acts like the function never existed - that is, it never calls the function.

What's wrong with the code? Could someone please send me a sample source code?

parksie
Aug 4th, 2001, 02:02 AM
You should change DllMain to get the HINSTANCE from there:BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD dwReason, LPVOID lpvReserved) {
if(dwReason == DLL_PROCESS_ATTACH) {
hinst = hinstDLL;
}

return TRUE;
}So, your CPL_INIT should now be:case CPL_INIT:
return TRUE;And finally, do you have a .def file for the DLL you're making? It should read something like:LIBRARY "test.dll"

EXPORTS
DllMain
CPlAppletTry that and see how you go :)