Click here to Skip to main content
15,904,817 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I'm trying to move a file with a simple timer in my console app. The timer seems to be working, however the file isn't moving. Any help is appreciated. Thak you.

C++
// Phonebooth.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <time.h>
#include <windows.h>
#include <iostream>

VOID CALLBACK TimerProc(
HWND hwnd, // handle to window
UINT uMsg, // WM_TIMER message
UINT_PTR idEvent, // timer identifier
DWORD dwTime // current system time
)
{
printf("Die, ****in' world\n");
rename("c:\\PASS\\airport.zip", "c:\\Users\\DS\\Downloads\\");
}

DWORD WINAPI ThreadProc(
LPVOID lpParameter // thread data
)
{
UINT uiTimer = ::SetTimer(NULL, 12354, 100, TimerProc);
	
	MSG msg;
	while (GetMessage(&msg, NULL, 0, 0))
	{
	// ranslateMessage(&msg);
		DispatchMessage(&msg);
	}
return 0;
}

int main()
{
HANDLE hThread = ::CreateThread(NULL, NULL, ThreadProc, NULL, NULL, NULL);
CloseHandle(hThread);
::Sleep(10000);
return 0;
}</iostream></windows.h></time.h>
Posted
Updated 31-Oct-11 18:28pm
v2
Comments
Sergey Alexandrovich Kryukov 1-Nov-11 0:19am    
Did you try to run it under debugger?
--SA
Member 7766180 1-Nov-11 0:27am    
Problem fixed. I forgot to add the file name to the second part! Time for bed.

1 solution

Add the file name to the second part.

C++
rename("c:\\PASS\\airport.zip", "c:\\Users\\DS\\Downloads\\airport.zip");
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900