|
-
Aug 2nd, 2001, 10:03 AM
#1
Thread Starter
Frenzied Member
Control Panel Application
I'm having a little problem with this code;
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?
Last edited by Microbasic; Aug 2nd, 2001 at 11:54 AM.
MicroBasic
Dragon Shadow Trainer
There is no good or evil in the world...only programmers and fools .
-
Aug 4th, 2001, 02:02 AM
#2
Monday Morning Lunatic
You should change DllMain to get the HINSTANCE from there:
Code:
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:
Code:
case CPL_INIT:
return TRUE;
And finally, do you have a .def file for the DLL you're making? It should read something like:
Code:
LIBRARY "test.dll"
EXPORTS
DllMain
CPlApplet
Try that and see how you go
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|