home *** CD-ROM | disk | FTP | other *** search
- #include "windows.h"
-
- // This file contains sample C code for writing a DLL that can be called
- // from a WIL Script file to build commands of the users own choosing.
- // This is the Windows 3.1 16 bit version
-
-
- char BugBypass[]="ABCDEFGHIJKLMNOPQRSTUVWXYZ"; //Superstitious inclusion
-
- HINSTANCE hThisInstance; //A place to save this DLL's instance handle
-
-
- /********************************************************************/
- int WINAPI WEP(int nP)
- {
- nP; // Never Referenced
- return 1;
- }
- /********************************************************************/
-
- BOOL WINAPI LibInit (
- HANDLE hInstance,
- WORD wDataSeg,
- WORD wHeapSize,
- LPSTR lpCmdLine)
- {
-
- hInstance;
- wDataSeg;
- wHeapSize;
- lpCmdLine;
-
- if (wHeapSize==0)
- {
- return FALSE;
- }
- if (!LocalInit(wDataSeg, NULL, (WORD)(NPSTR) wHeapSize)) return FALSE;
-
- hThisInstance=hInstance; // Save Instance Handle
- return TRUE;
- }
-
- /************************************************************************/
-
- // MyEntryPoint - the same as the second parameter of the DllCall statement
- GLOBALHANDLE WINAPI MyEntryPoint(HWND hWnd,LPSTR szParams)
- {
- char szAns[128];
- int i;
- GLOBALHANDLE ghTemp;
- LPSTR lpTemp;
-
-
- // Display message box showing passed parameters (szParams) wich is the
- // third argument of the DllCall statement
-
- MessageBox(hWnd,szParams,"DLL CALL TEST - Passed info is",MB_OK);
-
-
-
- // And now to show how to get a string back to a WIL variable. Only strings
- // may be returned. If you need to return a number....convert it to a
- // string first.
-
-
- // First of all manufacture an answer. We just load it from the RC file
- i=LoadString(hThisInstance,1,szAns,sizeof(szAns));
-
- // Then GlobalAlloc a memory buffer ONE BIGGER than the string
- ghTemp=GlobalAlloc(GMEM_MOVEABLE,(DWORD)i+1);
-
- if (ghTemp) // And if it was properly allocated
- {
- lpTemp=GlobalLock(ghTemp); // Lock it down and get a memory address
- if (lpTemp) // And if that worked,
- {
- lstrcpy(lpTemp,szAns); // Copy our answer to GlobalMemory
- GlobalUnlock(ghTemp); // Unlock the buffer
- }
- }
- return ghTemp; //Return unlocked buffer. WIL will free GlobalFree buffer
- }
-
-
-