Click here to Skip to main content
Licence CPOL
First Posted 6 Jun 2005
Views 18,484
Bookmarked 10 times

How use from a Dll in our programs.

By | 16 Sep 2005 | Article
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 : 

<P dir=ltr>1. BOOL IsWindowsNT(void)</P><P dir=ltr>2. CString GetPathWindows(void)</P><P dir=ltr>3. CString GetPathSystem(void)</P><P dir=ltr>4. CString GetDriveCDrom(void)</P>

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
//
// 
/////////////////////////////////////////////////<P></P>
<P dir=ltr>#include "stdafx.h"
#include "UseInfoWindowsDll.h"
#include "UseInfoWindowsDllDlg.h"</P>
<P dir=ltr> </P>
<P dir=ltr>#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static 
char THIS_FILE[] = __FILE__;
#endif</P>
<P dir=ltr>//----------Fuctions Dllfile----------</P>
<P dir=ltr>
HINSTANCE gLibMyDLL =NULL;</P>
<P dir=ltr>typedef CString (*GETPATHWINDOWS) (void);
GETPATHWINDOWS 
GetPathWindows;</P>
<P dir=ltr>
typedef CString (*GETPATHSYSTEM) (void);
GETPATHSYSTEM 
GetPathSystem;</P>
<P dir=ltr> </P>
<P dir=ltr>typedef  BOOL (*ISWINDOWSNT) (void);
ISWINDOWSNT 
IsWindowsNT;</P>
<P dir=ltr>
typedef CString (*GETDRIVECDROM) (void);
GETDRIVECDROM 
GetDriveCDrom;</P>
<P dir=ltr> </P><P dir=ltr>//----------------------
</P>

For Load Dll File , Written this code into OnInitDialog() :

//****************Dll file*********<P></P><P> 
 if(gLibMyDLL != NULL)
 {
  MessageBox("The InfoWindows.Dll Dll has already been loaded");
   return 0;
 }
 gLibMyDLL=LoadLibrary("InfoWidows.dll");</P>
<P> 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 <A href="file://WINDOWS//SYSTEM">file://WINDOWS//SYSTEM</A> directory.");
  MessageBox(msg);
 }</P>
<P> GetPathWindows=(GETPATHWINDOWS) GetProcAddress (gLibMyDLL,"GetPathWindows");
</P><P> </P><P> GetPathSystem=(GETPATHWINDOWS) GetProcAddress (gLibMyDLL,"GetPathSystem");
 </P><P> IsWindowsNT=(ISWINDOWSNT) GetProcAddress (gLibMyDLL,"IsWindowsNT");</P>
<P> GetDriveCDrom=(GETDRIVECDROM) GetProcAddress (gLibMyDLL,"GetDriveCDrom");
//*******************</P>

Continue :

<P>void CUseInfoWindowsDllDlg::OnButtonPathwindows() 
{
 // TODO: Add 
your control notification handler code here
 </P>
<P>   if(gLibMyDLL ==NULL)
 {</P>
<P> MessageBox("You must first load The DLL 
file");
 return;
 }</P>
<P>m_str2=GetPathWindows();
UpdateData(0);</P>
<P> </P>
<P>}</P>

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Behzad Bahjat Manesh



Iran (Islamic Republic Of) Iran (Islamic Republic Of)

Member

I am from Iran, and Live in Ardakan City.
I am Computer engineering (HardWare).
I programming in VC++ & C++ & Assembly & Basic

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralNice... Pinmemberaphazel4:38 11 Jan '10  
GeneralRe: Nice... PinmemberBehzad Bahjat Manesh5:24 20 Jan '10  
GeneralWindows in Iran PinmemberJonnoB8:27 6 Jun '05  
GeneralRe: Windows in Iran Pinmembermoliate12:33 13 Oct '05  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web04 | 2.5.120517.1 | Last Updated 17 Sep 2005
Article Copyright 2005 by Behzad Bahjat Manesh
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid