[WinAPI] СамоКопирование программы //РЕШЕНО! Пишу на С++. Скачал исходник один, что-то он не зработал. А с моим текущим инетом(3-4 кб/с), не могу найти нормально. Написал свой, но он тоже не работает. Code: int CopyMySelf() { LPTSTR Cdir, Sdir, thisF, thatF, currF; if ((GetWindowsDirectory(Sdir, sizeof(Sdir)-1) != 0) && (GetCurrentDirectory(sizeof(Cdir)-1, Cdir) != 0)) { GetModuleFileName(NULL, currF, sizeof(currF)-1); thisF = Cdir; thisF =+ currF; thatF = Sdir; thatF =+ currF; if (CopyFile(thisF, thatF, FALSE) != 0) { return 1; } else { return 0; } } else { return -1; } }
РЕШЕНО Code: #include <windows.h> int CopyMySelf() { TCHAR thisF[MAX_PATH]; TCHAR thatF[MAX_PATH]; if ((GetWindowsDirectory(thatF, sizeof(thatF)) != 0) && (GetModuleFileName(NULL, thisF, sizeof(thisF)) != 0)) { strcat (thatF, "\\fileName.exe"); MessageBox(NULL, thatF, "Error!", MB_OK); if (CopyFile(thisF, thatF, FALSE) != 0) { return 1; } else { return 0; } } else { return -1; } } Другой вопрос! Как это написать на С++?