on 2014 Nov 12 3:29 PM
Hi
I was trying to improve te speed of an application by offloading string manipulations to an external dll. I created a dll with two functions:
replace
fnstringreplace2
The fnstringreplace3 function just returns an int: 42. The replace function returns an int but accepts a string. in this string all '?' are replaced with a space. The declarations in C are as follows:
#ifdef STRINGREPLACE2_EXPORTS
#define STRINGREPLACE2_API __declspec(dllexport)
#else
#define STRINGREPLACE2_API __declspec(dllimport)
#endif
extern "C" STRINGREPLACE2_API int replace(TCHAR * string);
extern "C" STRINGREPLACE2_API int fnstringreplace2(void);
The code:
extern "C" STRINGREPLACE2_API int fnstringreplace2(void)
{
return 42;
}
extern "C" STRINGREPLACE2_API int replace(TCHAR * string) {
HRESULT res;
size_t maximalStringSize=1024;
size_t targetSize;
res = StringCchLength(string,maximalStringSize,&targetSize);
for(unsigned int i = 0;i < targetSize ;i++)
{
switch (string[i])
{
case '?':
string[i]=' ';
}
}
return 1;
}
The dll seems to work just fine. When I tried to use the dll in powerbuilder I can get the fnstringreplace2 function to work just fine but the replace function doesn't. IT says my arguments are invallid: see attachment.
My declarations in powerbuilder are:
FUNCTION int replace(ref string sayit) LIBRARY "stringreplace2.dll"
FUNCtION int fnstringreplace2() LIBRARY "stringreplace2.dll"
I tried also tried it with char* in the c++ code but this doesn't seem to make any difference.
Any help would be appreciated
Greetings
Vincent Mangelschots
Request clarification before answering.
When I add __stdcall then powerbuilder doesn't recognize the function anymore (bad runtime function at line x)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 8 | |
| 5 | |
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.