
Introduction
How use from a Dll in our programs.
this is a good example for this task.
this Dll is programed by me.(Name of Dll is InfoWindows.dll )
in this Dll , I use from Four Fuctions.
that are :
1. BOOL IsWindowsNT(void)
2. CString GetPathWindows(void)
3. CString GetPathSystem(void)
4. CString GetDriveCDrom(void)
1. Bool IsWindowsNT (void)
we can use this fuction to distinguish winNT from Win98.
2. CString GetPathWindows(void)
we can use this fuction to distinguish path of our installed windows.
3. CString GetPathSystem(void)
we can use this fuction to distinguish path of system folder.
4. CString GetDriveCDrom(void)
we can use this fuction to distinguish path of our CDrom.
Notice:
To useing Dll File we must be Copy Dll file into System Folder of our Windows.
See part of program together :
#include "stdafx.h"
#include "UseInfoWindowsDll.h"
#include "UseInfoWindowsDllDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static
char THIS_FILE[] = __FILE__;
#endif
HINSTANCE gLibMyDLL =NULL;
typedef CString (*GETPATHWINDOWS) (void);
GETPATHWINDOWS
GetPathWindows;
typedef CString (*GETPATHSYSTEM) (void);
GETPATHSYSTEM
GetPathSystem;
typedef BOOL (*ISWINDOWSNT) (void);
ISWINDOWSNT
IsWindowsNT;
typedef CString (*GETDRIVECDROM) (void);
GETDRIVECDROM
GetDriveCDrom;
For Load Dll File , Written this code into OnInitDialog() :
if(gLibMyDLL != NULL)
{
MessageBox("The InfoWindows.Dll Dll has already been loaded");
return 0;
}
gLibMyDLL=LoadLibrary("InfoWidows.dll");
if(gLibMyDLL ==NULL)
{
char
msg[300];
strcpy(msg,"Cannot load the DLL");
strcat(msg,"Make sure that the file DLL");
strcat (msg,"is in your file: directory.");
MessageBox(msg);
}
GetPathWindows=(GETPATHWINDOWS) GetProcAddress (gLibMyDLL,"GetPathWindows");
GetPathSystem=(GETPATHWINDOWS) GetProcAddress (gLibMyDLL,"GetPathSystem");
IsWindowsNT=(ISWINDOWSNT) GetProcAddress (gLibMyDLL,"IsWindowsNT");
GetDriveCDrom=(GETDRIVECDROM) GetProcAddress (gLibMyDLL,"GetDriveCDrom");
Continue :
void CUseInfoWindowsDllDlg::OnButtonPathwindows()
{
your control notification handler code here
if(gLibMyDLL ==NULL)
{
MessageBox("You must first load The DLL
file");
return;
}
m_str2=GetPathWindows();
UpdateData(0);
}