DLL, export bool dfunc(char[] s, extern (Windows) bool function() cb)
Bjoern
nanali at nospam-wanadoo.fr
Tue Jan 15 07:11:20 PST 2008
Subject; DLL function calls callback function in callee (parent)
like
// MyDLL a Dll written in D
export bool dfunc(char[] s,extern (Windows)char[] function() cb)
{
while ( char[] t = tokenize(s)) cb(t);
return true;
}
I have to use some 4GL code to explain:
FUNCTION GetResult(StringToAnanlyse is string = "Hello from 4GL")
// Call dfunc , pass StringToAnalyse, and address of CallBack Function
IF API("MyDLL", "dfunc", StringToAnanlyse, &ReceiveResult)
END
// The CallBack Function
PRIVATE FUNCTION ReceiveResult(token is string)
WHILE token <> ""
Trace(token)
newString += (token + ",") // defined elsewhere
END
RESULT newString
// Output
Hello
from
4GL
newString == "Hello,from,4GL,"
---------------------------------------------------
I ask here instead of D.lean because I mean the official "DLLs in D"
documents should explain this functionality too.
Oh, the question :)
export bool dfunc(char[] s, extern (Windows) char[] function() cb)
I think at least my intention is clear , so I hope somebody is willing
to show me how to implement such a DLL function.
Many thanks in advance, Bjoern
More information about the Digitalmars-d
mailing list