#include "stdafx.h"
using namespace std;
#define EXPORT extern "C" __declspec(dllexport)
EXPORT int testfunction(const int test) {
return test * 3;
}
This works fine with PB and CallCFunction(Fast). But, i need to create dll which use CallFunction(Fast) and not CallCFunction(Fast). I'm interested if that is possible.
Thanks for response, Fred. I tried it before but then i must call it with CallFunction(dll,"_testfunction@4",1).
A problem is, i am writing a plugin for application written in PureBasic which has hardcoded function names and uses CallFunction() and now there is prefix '_' and suffix '@4' so it doesn't recognize that dll as its plugin.
The only solution i see now it would be to create lib with Visual Studio and then create dll in PureBasic and use ImportC to create wrapper for that library.
Or is there something else i can do to create dll with function names without '_' and '@' that uses stdcall?
LibFunc = LoadLibrary_("my.dll")
If LibFunc
*Func = GetProcAddress_(LibFunc, "MyFunction")
If *Func
CallFunctionFast(*Func, parameter, parameter, parameter, parameter, etc...) ; Just ever how many parameters are needed for function
EndIf
EndIf
FreeLibrary_(LibFunc)
The advantage of a 64 bit operating system over a 32 bit operating system comes down to only being twice the headache.
@SFSxOI: I only need Visual Studio C++ source code for creating a dll which can be opened in PureBasic with that code that you just posted but currently it needs to be "_MyFunction@4" and i need it to be opened with "MyFunction".
@klaver: I will try that. It could be a little inconvenience but if it works... then great.
SFSxOI wrote:why don't you just convert the C++ source to PureBasic?
Because:
*not everyone has PureBasic so i want to make simple plugin template for compiling plugin (dll) with C++ compilers, and
*main application has already shipped with hardcoded function names in CallFunction().
klaver wrote:cas, open the .dll in a HEX editor and replace "_testfunction@4" with "testfunction".
I tried it today and it looks like it works
But... i found solution without editing dll with hex editor. In Visual Studio i set custom definition file in: Project Properties -> Linker -> Input -> Module Definition File and now it creates stdcall dll without '_' and '@', just like PureBasic does.