1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
|
#include <windows.h>
#include <windowsx.h>
#include <stdio.h>
#include "vbdialog.h"
#pragma hdrstop
static HINSTANCE hInst;
char *code_fichier,*code_index,*lgcle;
char cle_rech[20];
char *bufferDest;
WORD *code_fich_ind;
//déclaration des fonctions de la DLL
typedef int (WINAPI *DLL_Function_X_LEC_ART_CLE_DTA) (WORD lgCle,WORD cdeFicInd,LPSTR cleRech,WORD adNumEnreg,LPSTR src,LPSTR dest);
DLL_Function_X_LEC_ART_CLE_DTA pfn_X_LEC_ART_CLE_DTA;
LONG FAR PASCAL SamplesDialog (HWND hWnd,WORD wMsg,WORD wParam,LONG lParam)
{
//chargement de la dll
HMODULE hDLL = LoadLibrary("TestDLL.dll");
pfn_X_LEC_ART_CLE_DTA = (DLL_Function_X_LEC_ART_CLE_DTA) GetProcAddress(hDLL,"X_LEC_ART_CLE_DTA");
// process the message
switch( wMsg )
{
// process command from one of the child controls
case WM_COMMAND:
switch( GET_WM_COMMAND_ID(wParam,lParam) )
{
// ok or cancel, so end the dialog
case IDOK:
code_fichier = malloc(sizeof(char));
code_index = malloc(sizeof(char));
lgcle = malloc(sizeof(char));
code_fich_ind = malloc(2*sizeof(char));
bufferDest = malloc(20*sizeof(char));
GetDlgItemText(hWnd,IDC_CODEFICHIER,code_fichier,2);
GetDlgItemText(hWnd,IDC_CODEINDEX,code_index,2);
GetDlgItemText(hWnd,IDC_LGCLE,lgcle,2);
GetDlgItemText(hWnd,IDC_CLERECH,cle_rech,20);
code_fich_ind = strcat(code_fichier,code_index);
pfn_X_LEC_ART_CLE_DTA(*lgcle,*code_fich_ind,cle_rech,5,"C.HEA",&bufferDest);
SetDlgItemText(hWnd,IDC_MSG,bufferDest);
MessageBox( NULL,bufferDest , NULL, MB_OK | MB_APPLMODAL );
break;
case IDCANCEL:
EndDialog(hWnd, 0 );
break;
}
break;
// initialize the dialog
case WM_INITDIALOG:
return FALSE;
}
FreeLibrary(hDLL);
return FALSE;
}
// Turn off warning: Parameter * is never used in function WinMain...
#pragma argsused
int PASCAL WinMain (HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpszCmdLine,int nCmdShow)
{
// save the instance
hInst = hInstance;
// load the samples dialog box
if( DialogBox( hInstance, "Samples", NULL, (FARPROC)SamplesDialog ) == -1 )
MessageBox( NULL, "Can't load dialog box!\n", NULL, MB_OK | MB_APPLMODAL );
// end of program
return 0;
} |
Partager