Login
`
Templates, Tools and Utilities
|
||
Icetips Article
Back to article list
Search Articles
Add Comment
Printer friendly
Direct link
Other Languages - using Clarion with...: C++ Calling clarion functions from VC 2002-11-28 -- Jim Kane Newsgroups: comp.lang.clarion
I wrote a clarion dll to read tps files from vc. I did not use (I never
use) mfc or atl. This was a straight C app.
in callfile.c
case WM_CREATE:
hInstance = ((LPCREATESTRUCT) lParam)->hInstance;
hdc = GetDC (hwnd) ;
GetTextMetrics (hdc, &tm) ;
cxChar = tm.tmAveCharWidth ;
cxCaps = (tm.tmPitchAndFamily & 1 ? 3 : 2) * cxChar / 2 ;
cyChar = tm.tmHeight + tm.tmExternalLeading ;
ReleaseDC (hwnd, hdc) ;
//load the clarion dll
hGetFile =
LoadLibrary(TEXT("GETFILE.DLL"));
if(!hGetFile == 0)
{
PD_Init =
)GetProcAddress(hGetFile,"PD_INIT");
PD_SetDataPath =
D_SETDATAPATH )GetProcAddress(hGetFile,"PD_SETDATAPATH");
PD_GetBufferSize =
(PD_GETBUFFERSIZE )GetProcAddress(hGetFile,"PD_GETBUFFERSIZE");
PD_OpenFile =
PENFILE )GetProcAddress(hGetFile,"PD_OPENFILE");
//more code here
}
else
{
MessageBox(hwnd,"LoadLib Failed for GetFile.dll","Fatal Error", MB_OK);
SendMessage(hwnd,WM_CLOSE,0,0);
return(1);
}
if(PD_Init == 0 || PD_SetDataPath==0 || PD_OpenFile==0 ||
PD_GetBufferSize==0 ||
//more code here
)
{
MessageBox (hwnd, TEXT("Wrong version of GetFile.Dll"), TEXT("Fatal
Error"), MB_OK);
SendMessage(hwnd,WM_CLOSE,0,0);
return(1);
}
PD_Init(); //Init the dll
//rest of the program here......
then in callfile.h the prototypes
#ifndef CALLFILE_H
#define CALLFILE_H
#ifdef __cplusplus
extern "C" {
#endif
//Function Prototypes
typedef void (WINAPI * PD_INIT)(void);
PD_INIT PD_Init;
typedef unsigned char (WINAPI * PD_SETDATAPATH )(LPCSTR lpDataPath);
PD_SETDATAPATH PD_SetDataPath;
typedef unsigned char (WINAPI * PD_GETBUFFERSIZE)(LPCSTR lpFileLabel,
LPDWORD cbBuffer);
PD_GETBUFFERSIZE PD_GetBufferSize;
typedef unsigned char (WINAPI * PD_OPENFILE)(LPCSTR lpFileLabel, LPCVOID
lpBuffer, DWORD cbBuffer);
PD_OPENFILE PD_OpenFile;
typedef unsigned char (WINAPI * PD_CLOSEFILE)(LPCSTR lpFileLabel);
PD_CLOSEFILE PD_CloseFile;
//other prototypes here
//Equates
// Error Equates - Usually returned as a byte (unsigned char)
#define levelbenign 0 //No Error
#define levelfatal 3 //Error - Action did not complete
#define levelnotify 5 //Action didnt complete but not an error - typically
End of File
//Cstring size for File and Key Labels
#define LabelLen 41
#ifdef __cplusplus
};
#endif
#endif
Jim Kane
"Mihai Palade (Bucharest - Romania)"
Today is November 21, 2024, 3:49 am This article has been viewed 35444 times. Google search has resulted in 317 hits on this article since January 25, 2004.
|
|