Interprocess Communication'a gerek olduğunu düşünmüyorum. Win32 API'sindeki LoadLibrary()
fonksiyonu ile DLL'yi yükleyerek GetProcAddress()
fonksiyonuyla da aradığın fonksiyonun olup olmadığını bulabilirsin. Tabii ki "calling convension" dediğimiz hedenin de burada önemi mevcut; GetProcAddress()
fonksiyonunun DLL'deki o fonksiyonu bulabilmesi için fonksiyonun "export" edimiş olması lazım.
[CODE lang="cpp" title="Uygulama"]#include <windows.h>
#include <iostream>
/*
Bu tanım, int_fptr'nin int türünden değer döndüren ve hiçbir argüman almayan
fonksiyona işaretçi olduğunu tanımlıyor.
*/
typedef int (__stdcall *int_fptr)();
int main()
{
HINSTANCE dll_instance = LoadLibrary("test.dll");
if (!dll_instance) {
std::cout << "Gerekli olan kutuphane bulunamadi." << std::endl;
return EXIT_FAILURE;
}
// fonksiyon adresinin çözümü
int_fptr function = (int_fptr)GetProcAddress(hGetProcIDDLL, "test_function");
if (!function) {
std::cout << "Kutuphanede aranilan fonksiyon bulunamadi." << std::endl;
return EXIT_FAILURE;
}
std::cout << "Fonksiyon donus degeri: " << function() << std::endl;
return EXIT_SUCCESS;
}[/CODE]
[CODE lang="cpp" title="Örnek DLL fonksiyonu giriş kodu"]int __stdcall __declspec(dllexport) test_function(){
//kod
}[/CODE]