Sign in to follow this  
Followers 0
monoceres

Calling my own dll causes crash.

7 posts in this topic

Sorry for being needy this last couple of days but I'm just running into problem after problem.

Today I tried to make a dll that would just wrap another function, but it just keeps on crashing :)

Here's my c++ code:

#include <windows.h>
extern "C" __declspec(dllexport) void _SetPixel(HDC dc,int x, int y, unsigned int color)
{

SetPixel(dc,x,y,color);

}

And here's my autoit code:

#include <GDIPlus.au3>
#include <Winapi.au3>
$hwnd=GUICreate("hello",300,200)
GUISetSTate()


_GDIPlus_Startup()
$graphics=_GDIPlus_GraphicsCreateFromHWND($hwnd)
_GDIPlus_GraphicsClear($graphics,0xFFFFFFFF)
$dc=_GDIPlus_GraphicsGetDC($graphics)
DllCall("GDIplusplus.dll","none","_SetPixel","ptr",$dc,"int",10,"int",10,"dword",0xFF0000)
Do
    $msg=GUIGetMsg()
Until $msg=-3

_GDIPlus_GraphicsReleaseDC($graphics,$dc)
_GDIPlus_GraphicsDispose($graphics)
_GDIPlus_Shutdown()

I can see that the pixel gets painted and everything but right after that it's just a big crash!

Ps. I do know that I could call the Setpixel function like this: DllCall("gdi32.dll", "int", "SetPixel", "ptr", $dc, "int", 10, "int", 10, "dword",0xFF0000)

but I'm after the principle.

:P


Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites



See the Remarks of DllCall reference in helpfile. Particularly the paragraph about calling conventions.


"be smart, drink your wine"

Share this post


Link to post
Share on other sites

See the Remarks of DllCall reference in helpfile. Particularly the paragraph about calling conventions.

Thanks, I got it working :)

How do I make a dll that uses stdcall instead?

__stdcall gives me lots of errors in Visual studio 2008..


Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites

Thanks, I got it working :)

How do I make a dll that uses stdcall instead?

__stdcall gives me lots of errors in Visual studio 2008..

Why would you bother with stdcall?

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Why would you bother with stdcall?

I really don't know, but since i never even saw the "Function DllCallint:cdecl" syntax before I figured that stdcall was some sort of standard that would be good to follow or something.

But I really don't know that much about this so I guess I will do fine with cdecl. :)


Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites

I really don't know, but since i never even saw the "Function DllCallint:cdecl" syntax before I figured that stdcall was some sort of standard that would be good to follow or something.

But I really don't know that much about this so I guess I will do fine with cdecl. :)

I write all mine in cdecl.

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0