Skip to content
This repository has been archived by the owner on Jan 13, 2023. It is now read-only.

luboslenco/kha_calldll

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

kha_calldll

Example on calling a C++ function from .dll on Windows. Visual Studio project for the library being loaded is located at /Win32Project1. This project exports a function:

__declspec(dllexport) int __cdecl testFunction() {
	return 6;
}

Afterwards, the function is called from Haxe:

static function callDll():Int {
	// ...
	untyped __cpp__('hinstLib = LoadLibrary(TEXT("Win32Project1.dll"));');
	untyped __cpp__('procAddr = (MYPROC)GetProcAddress(hinstLib, "testFunction");');
	var result = 0;
	untyped __cpp__('result = (procAddr)();');
	// ...
}

Clone repository and run:

git clone --recursive https://github.com/luboslenco/kha_calldll
node Kha/make --run

Expected output:

Main.hx:36: Result: 6

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages