July 19th, 2000, 12:03 PM
How do I get the list and icons of the control panel applets that are available on the system? Not every system has the same applets, it depends on what is installed, and what the OS is. And there are also 3rd party applets. They all are in .CPL files in the system folder. Those files are renamed DLLs, with only one interface, CPLApplet. From vb, you can use loadlibrary to load the cpl file you find, which returns the file handle. Then in that file you can get the applet memory address with the API getprocaddress(libraryhandle, "CPlApplet"). Then you declare a variable of a vb user type that looks like the CPOApplet object:
Public Type CPLApplet
hwndCPl As Long ' in, hwnd of main window controlling the app or null
uMsg As Integer ' in, Message being sent to the Control Panel application
lParam1 As Long ' out, Additional message-specific information
lParam2 As Long ' out, Additional message-specific information
End Type
Dim aCPLApplet As CPLApplet
I set up the uMsg flag to initialize the applet object in the cpl file:
aCPLApplet.hwndCPl = vbNull
aCPLApplet.uMsg = CPL_INIT
Then I use movememory to move the data from my local vb cplapplet object to the applet proc address:
MoveMemory GetProcAddress(LibHandle, "CPlApplet"), aCPLApplet, Len(aCPLApplet)
Then I change the flag to get the applet count in that cpl file:
aCPLApplet.uMsg = CPL_GETCOUNT
and I resend my local structure to the applet address.
MoveMemory GetProcAddress(LibHandle, "CPlApplet"), aCPLApplet, Len(aCPLApplet)
This is as far as I got. I have tried looking at memory at the applet address to get the first 4 bytes, but they are no number. Any better ideas to get the data back from the cpl file applet object?
Thanks,
Xavier
Public Type CPLApplet
hwndCPl As Long ' in, hwnd of main window controlling the app or null
uMsg As Integer ' in, Message being sent to the Control Panel application
lParam1 As Long ' out, Additional message-specific information
lParam2 As Long ' out, Additional message-specific information
End Type
Dim aCPLApplet As CPLApplet
I set up the uMsg flag to initialize the applet object in the cpl file:
aCPLApplet.hwndCPl = vbNull
aCPLApplet.uMsg = CPL_INIT
Then I use movememory to move the data from my local vb cplapplet object to the applet proc address:
MoveMemory GetProcAddress(LibHandle, "CPlApplet"), aCPLApplet, Len(aCPLApplet)
Then I change the flag to get the applet count in that cpl file:
aCPLApplet.uMsg = CPL_GETCOUNT
and I resend my local structure to the applet address.
MoveMemory GetProcAddress(LibHandle, "CPlApplet"), aCPLApplet, Len(aCPLApplet)
This is as far as I got. I have tried looking at memory at the applet address to get the first 4 bytes, but they are no number. Any better ideas to get the data back from the cpl file applet object?
Thanks,
Xavier