Advertisement
Java_Volume1 Miscellaneous #100189

Code Example - How to Load , and Release a DLL, Get a Proccess's Address, and invoke it

Someone asked me how to load a DLL, and call a function, and then release it. Also asked for OCX and some other format, that I am not familar with. Since PSC still wont let me upload, I just made it a quick little dos program for you to examine how it works. If I have time ill look up on OCX.

AI

AI Summary: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Source Code
original-source
// code request for planetsourcecode
// written by Jared Bruni
// for planetsourcecode
// dear person who request this
// I am not familar with OCX or the other API
// however I am familar with DLL
// so sorry about the others, but heres how to use DLL

#include <iostream.h>
#include <windows.h>
// im doing this in dos, so I can just show you how to mess with the API
// gohead and take this and apply it within your own code
// whenever I get a DLL I use inline assembly to manualy push it into the stack
// into the stack, and then call the instruction
// im not sure if there is a simpler way, but this is my way
// LoadLibrary (theDLL) ; // load sthe dll
// FreeLibrary (HMODULE); // free the DLL
// GetProcAddress (hModule,"FunctionName"); // get hep rocce
HMODULE thedll;
FARPROC proc;

// this would load up , kernel 32 
// and remove are program from the control+alt+delete
void main()
{
	cout << "example, manipulating the DLL without the library file" << endl;
	cout << "specificly for planetsourcecode " << endl;
	thedll = LoadLibrary("kernel32.dll");
	proc = GetProcAddress(thedll,"RegisterServiceProcess");
	
	__asm
	{
		push 1
		push 0
		call proc
	}
	FreeLibrary(thedll);
}
// if I find out how to do OCX, etc, ill be sure to post it
// - Jared

Upload
Upload
Original Comments (3)
Recovered from Wayback Machine