65.9K
CodeProject is changing. Read more.
Home

How use from a Dll in our programs.

starIcon
emptyStarIcon
starIcon
emptyStarIconemptyStarIconemptyStarIcon

1.06/5 (11 votes)

Jun 6, 2005

CPOL
viewsIcon

26280

downloadIcon

318

Use from a Dll file .this is a good example for this task.

Sample Image - UseInfoWindows_behzadbahjatmanesh.gif

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 :

// UseInfoWindowsDllDlg.cpp : implementation file
// 
/////////////////////////////////////////////////
//
// Programmer : Behzad Bahjat Manesh .
// Date : 2005/06/06
// Email :Bahjatmanesh@gmail.com
//
// 
/////////////////////////////////////////////////

#include "stdafx.h" #include "UseInfoWindowsDll.h" #include "UseInfoWindowsDllDlg.h"

 

#ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif

//----------Fuctions Dllfile----------

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() :

//****************Dll file*********

   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://WINDOWS//SYSTEM 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() {  // TODO: Add your control notification handler code here  

   if(gLibMyDLL ==NULL)  {

 MessageBox("You must first load The DLL file");  return;  }

m_str2=GetPathWindows(); UpdateData(0);

 

}