Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define PathToLibrary "D:\\NativeLibrary.dll"
- #include "windows.h"
- #define symLoad GetProcAddress
- #include <stdlib.h>
- #include <stdio.h>
- int callSumFunc(char* path, char* funcName, int a, int b);
- int main()
- {
- if (!access(PathToLibrary, 0))
- printf("File Present");
- else
- printf("File not Found");
- // Sum two integers
- int sum = callSumFunc(PathToLibrary, "add", 2, 8);
- printf("The sum is %d \n", sum);
- }
- int callSumFunc(char* path, char* funcName, int firstInt, int secondInt)
- {
- // Call sum function defined in C# shared library
- HINSTANCE handle = LoadLibrary(PathToLibrary);
- DWORD ErrorCode = GetLastError();
- typedef int (*myFunc)();
- myFunc MyImport = (int)symLoad(handle, funcName);
- int result = MyImport(firstInt, secondInt);
- // CoreRT libraries do not support unloading
- // See https://github.com/dotnet/corert/issues/7887
- return result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement