www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - function pointer from DLL

reply "DNewbie" <run3 myopera.com> writes:
I've been trying to translate the following from

int (*fn)(void*,int,int,int);
void * ptr;
int canundo;

fn = (int (__cdecl *)(void *,int,int,int))SendMessage(
ptr = (void *)SendMessage(hwndScintilla,SCI_GETDIRECTPOINTER,0,0);
canundo = fn(ptr,SCI_CANUNDO,0,0);

And I got a run time error while running 'fn(ptr, SCI_CANUNDO, 0, 0);':

int function (void*,int,int,int) fn;	
fn = cast(int function(void*,int,int,int)) SendMessage(
	hwndScintilla, SCI_GETDIRECTFUNCTION, 0, 0);

void *ptr = cast(void *)SendMessage(hwndScintilla, SCI_GETDIRECTPOINTER, 0, 0);

fn(ptr, SCI_CANUNDO, 0, 0);
Run time error: object.Error: Access Violation

Then I've tried
extern (C) int function (void*,int,int,int) fn;	
fn = cast(extern (C) int function(void*,int,int,int))SendMessage(
	hwndScintilla, SCI_GETDIRECTFUNCTION, 0, 0);
Compilation error: basic type expected, not extern

Could someone point me in the right direction.
Jan 13 2012
parent "DNewbie" <run3 myopera.com> writes:
On Sat, Jan 14, 2012, at 06:04 AM, Andrej Mitrovic wrote:
 On 1/14/12, Andrej Mitrovic <andrej.mitrovich gmail.com> wrote:
 You can clone this: git github.com:AndrejMitrovic/DSciteWin.git

 Then just run build.bat.
Sorry, I've assumed you run git, the http link is: https://github.com/AndrejMitrovic/DSciteWin
Yeah! Rock'n'roll! Thank you.
Jan 13 2012