|
-
November 6th, 2004, 08:06 PM
#1
rundll32 implementation
hello there,
i have the following problem:
i want to implement my own function just like rundll32, so
i could open from my funtion for example the "System Clock Properties Window" (double click over the clock icon) just like
with rundll32 (e.g.: c:\>rundll32 shell32,Control_RunDLL TimeDate.cpl,,0 -> opens
the Clock properties...), so
i read the documentation in MSDN about how rundll32 works and
wrote the following code:
Code:
#define LEAN_AND_MEAN
#include <windows.h>
#include <winbase.h>
typedef LPVOID (CALLBACK* DLLFUNC)(LPSTR);
int main()
{
HMODULE hMod = NULL;
DLLFUNC ProcAdd = NULL;
hMod = LoadLibrary("c:\\winnt\\system32\\shell32.dll");
if (hMod != NULL)
{
if (hMod)
{
ProcAdd = (DLLFUNC) GetProcAddress(hMod, "Control_RunDLL");
if (ProcAdd)
{
(DLLFUNC) ProcAdd("TimeDate.cpl,,0");
}
}
FreeLibrary(hMod);
}
return 0;
}
but the program crash after calling "(DLLFUNC) ProcAdd(..." code line.
i've tried also to declare the DLLFUNC like this "EntryPoint function" just like in MSDN with the 4 parameters (hwnd, hInstance, etc.) but didn't work also ...
I think the problem is, because "Control_RunDLL" takes somehow different parameters and i can't call the function correct.
Does anyone have an idea what's going on and how should i implement this correct?
thank you in advance,
typecast
-
November 7th, 2004, 05:07 AM
#2
Re: rundll32 implementation
I believe the correct signature for Rundll32 is:
Code:
typedef void (CALLBACK *DLLFUNC)(HWND,HINSTANCE,LPTSTR,int);
simple example of call...
Code:
(DLLFUNC)(GetDesktopWindow()
, 0
, "\\windows\\system32\\timedate.cpl"
, 0
);
-
November 7th, 2004, 07:16 AM
#3
Re: rundll32 implementation
hi there :-)
thank you for your reply.
the program still doesn't start the "clock properties window" but at least
doesn't crash anymore :-)
i'll keep trying and when i get it (if i get it), i post the solution here.
with best regards,
typecast
-
November 7th, 2004, 07:18 AM
#4
Re: rundll32 implementation
ok, i got it :-)
you just need to give the whole path .. stupid me :-))
thank you!! 
typecast
Code:
#define LEAN_AND_MEAN
#include <windows.h>
#include <winbase.h>
#include <winuser.h>
typedef LPVOID (CALLBACK* DLLFUNC)(HWND, HINSTANCE, LPTSTR, int);
int main()
{
HMODULE hMod = NULL;
DLLFUNC ProcAdd = NULL;
hMod = LoadLibrary("c:\\winnt\\system32\\shell32.dll");
if (hMod != NULL)
{
if (hMod)
{
ProcAdd = (DLLFUNC) GetProcAddress(hMod, "Control_RunDLL");
if (ProcAdd)
{
(DLLFUNC) ProcAdd(GetDesktopWindow(), 0,"c:\\winnt\\system32\\TimeDate.cpl",0);
}
}
FreeLibrary(hMod);
}
return 0;
}
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
|