Jump to content
Tuts 4 You

Createthread in x64


ToMKoL

Recommended Posts

Hi all

I'm trying to compile simple c program with animated title bar (swapping letter case) but unfortunately I'm stuck with CreateThread in x64. Here is my sample code:

DWORD WINAPI animate(HWND hWnd);
HANDLE hthread;

case WM_INITDIALOG:
		SendMessageA(hWnd, WM_SETICON, (WPARAM) 1, (LPARAM) LoadIconA(hInst, MAKEINTRESOURCE(IDI_ICON)));
		hthread = CreateThread(0, 0, animate, hWnd, 0, 0);

DWORD WINAPI animate(HWND hWnd)
{
	unsigned char wincaption[24];
	unsigned int i;
	SendMessageA(hWnd, WM_GETTEXT, 24, (LPARAM)wincaption);
	do
	{
		for(i=0;i<19;i++)
		{
			if (((wincaption[i] >= 0x41) && (wincaption[i] <= 0x5A)) || ((wincaption[i] >= 0x61) && (wincaption[i] <= 0x7A)))
				wincaption[i] ^= 0x20;
			SendMessageA(hWnd, WM_SETTEXT, 0, (LPARAM)wincaption);
			Sleep(500);
		}
	}
	while (1);
	return 0;
}

Full package attached. It compiles to "mov r8, qword ptr [animate]" instead of "mov r8, offset animate". If compiled to x32 everything is fine. Can someone point me my error.

Thanks in advance

test.zip

Link to comment

It probably depends on which compiler & what settings you use. My VS2019 builds your code perfectly for both x86 and x64.

 

If your compiler keeps being stupid, try using this:

hthread = CreateThread(0, 0, &animate, hWnd, 0, 0);
  • Thanks 1
Link to comment

Thanks. Tried that also and don't work. Compiles the same way. Will change compiler (using old LCC) to VS community (at least free version).

Link to comment

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
×
×
  • Create New...