Jump to content

Help| How To Load and Use DLL

- - - - -

  • Please log in to reply
3 replies to this topic

#1
PogBender

PogBender

    Newbie

  • Members
  • Pip
  • 5 posts
How do i Load and Use DLL
in C++

does it matter if its VB DLL or C++ DLL ?
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

i tried c++ DLL:



Func.cpp:
double __stdcall Squ (double & X)

{

	return (X*X);

}

FuncDef.def:
LIBRARY "Func"

EXPORTS

Func


and i added the FuncDef.def to Linker >Input


vb Side:(problem)

Attached File  בעיה.png   34.06K   7 downloads


ty :P

Edited by PogBender, 08 December 2011 - 09:41 AM.


#2
lespauled

lespauled

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 231 posts
  • Programming Language:C, C++, C#, JavaScript, PL/SQL, Delphi/Object Pascal, Visual Basic .NET, Pascal, Transact-SQL, Bash
If it's VC++, this may help

How to load a dynamic link library (DLL) into a Microsoft Visual C++ 6.0 project - CodeProject

#3
bbqroast

bbqroast

    Codecall Addict

  • Members
  • PipPipPipPipPipPipPip
  • 554 posts
  • Location:/etc/passwd
Seeing as VB and C++ are different languages it probably does...
What DLL specifically? Also check out LazyFoos installing SDL tutorials, should give you the general gist of things...
Please, write clearly with proper structure. Double spacing makes the text feel un-jointed, Capitalizing Every Word Means People Stop Before Every Word Sub-Consciously Which Is A Pain In The Backside, and use code tags! (The right most styling box).

#4
mebob

mebob

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 490 posts
Are you asking how to dynamically load a DLL into your program? If so, here is an example piece of code I wrote for a friend.


#include <windows.h>

#include <iostream>


using namespace std;


//This makes the function pointers easier

typedef int (__cdecl *DLLCALL)();


int main()

{

	HINSTANCE library;

	DLLCALL testing = NULL;


	////This here loads the DLL and points the library HINSTACE to it

	library = LoadLibrary("dlltest.dll");


	////This makes sure it loaded correctly. If it did, then library shouldn't equal NULL. It will continue onward.

	if(library != NULL)

	{

		////This is the function that gets the function named "testing" out of the DLL. It "stores" it in the variable

		////I created at the top of the main function, testing.

		testing = (DLLCALL) GetProcAddress(library, "testing");


		////If the function loaded correctly, run this code.

		if(testing != NULL)

		{

			////The "testing" function i created in the DLL code just returns 100. So, this will print 100.

			cout << testing();

		}

		////Unload the library.

		FreeLibrary(library);

	}

}


It uses a simple testing DLL I wrote that contains a function named testing() that simply returns 100

Edited by mebob, 07 December 2011 - 02:26 PM.

Latinamne loqueris?




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users