(So what happened to your original problem of passing the string from a
ok ok, to reveal the whole story:
I'm using a pdf-2-text-converter-function from an external vendor which
resides within a dll. This dll forces me to write a callback-function, which
is called when a pdf-file is to be converted. Within this callback-function,
I get a char* that points to the buffer containing the result of the
pdf-converting. The callback function looks like this:
void ContentCallBackFunc(char* i_szStr, int i_size)
{ myBuf = i_szStr; // myBuf is global char*-variable
mySize = i_size; // mySize is global int-variable
}
Now I'm about to write a wrapper around this function (it's again a dll), so
that I can pass in the filename to the pdf-file and get the buffer
containing the converting data back. Let's say a function called
Convert(...) looks something like this:
extern "C" __declspec(dllexport)
void Convert(const char* filename, char **buffer, int *length)
{
convertPdf(filename, (CALLBACK)ContentCallBackFunc); // make use
of the convert-Pdf-function of the external dll --> this implies a call to
ContentCallBackFunc
*buffer = myBuf; // specify output-params
*length = mySize;
}
In any win32-client-program I can use now this external
Convert(...)-function and I shall be able to access the converted buffer. I
make use in a win32-console-app like this:
extern "C" __declspec(dllimport) void Convert(const char* filename, char
**buffer, int *length);
int _tmain(int argc, _TCHAR* argv[])
{
char* buffer = NULL;
int length = -1;
Convert("C:\\test.pdf", &buffer, &length);
printf("Buffer:\t%d\t%s\n", length, buffer); // results in an
memory-access-error!
}
The real question over dll-boundaries is now, whether it is possible to
access the original-buffer from the callback-function just by redirecting
some pointers, or if I have to copy the original pointer to a buffer into a
second buffer-array to be able to access it from another application!?
The key is that I want to avoid copying buffers whenever it is possible,
because my application is very time-critical and eventually it should call
that converting-function thousands of times within a short period. So I
really would prefer just redirecting pointers instead of copying buffers.
So this is true story and real background to my initial question.
Would be fine to receive any hints,
ekim!