home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
High Voltage Shareware
/
high1.zip
/
high1
/
DIR8
/
WE_30C.ZIP
/
DLLCALL.ZI_
/
DCTST32X.C
< prev
Wrap
C/C++ Source or Header
|
1993-07-30
|
2KB
|
69 lines
#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 NT 32 bit version
char BugBypass[]="ABCDEFGHIJKLMNOPQRSTUVWXYZ"; //Superstitious inclusion
HINSTANCE hThisInstance; //A place to save this DLL's instance handle
// ************************************************************************
// FUNCTION : LibMain( HANDLE, DWORD, LPVOID )
// PURPOSE : LibMain is called by Windows when
// the DLL is initialized, Thread Attached, and other times.
// Just save DLL Instance here.
// ************************************************************************
BOOL WINAPI LibMain( HANDLE hInst, DWORD dwReason, LPVOID lpReserved )
{
hThisInstance= hInst;
UNREFERENCED_PARAMETER( dwReason );
UNREFERENCED_PARAMETER( lpReserved );
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
}