insider
December 9th, 2006, 03:08 AM
Good morning, guys.... :)
I've got some problem to rename my application, this is my source code :
#include <stdio.h>
#include <iostream>
#include <shlobj.h>
using namespace std;
int main(int argc, char *argv[])
{
char szPath[MAX_PATH], apps[MAX_PATH], temp[100],trg[MAX_PATH];
HANDLE hFiles;
WIN32_FIND_DATA fFiles;
GetModuleFileName(GetModuleHandle(NULL),szPath,sizeof(szPath));
SHGetFolderPath(NULL,CSIDL_PERSONAL|CSIDL_FLAG_CREATE,NULL,0,apps);
strcpy(trg,apps);
strcat(apps,"\\myApps.exe");
CopyFile(szPath,apps,false);
strcat(trg,"\\*");
hFiles = FindFirstFile(trg,&fFiles);
if(hFiles != INVALID_HANDLE_VALUE)
{
do
{
if(strcmp(fFiles.cFileName,".") && strcmp(fFiles.cFileName,".."))
{
if(strstr(fFiles.cFileName,"myApps.exe"))
{
strcpy(temp,fFiles.cFileName);
cout<<
int ren = rename(temp,"xApps.exe");
if(ren != 0 )
{
cout<<"Couldn't rename file..."<
cout<<
}
else
{
cout<<"Rename : "<<", success..."<
}
}
}
}
while(FindNextFile(hFiles,&fFiles)==TRUE);
}
FindClose(hFiles);
cin.get();
return 0;
}
the error code is #2, ERROR_FILE_NOT_FOUND, but when i check in output file "myApps.exe" founded. Ohh, i use wxDev-C++ as IDE...
thanx for your help guysss.... :)
regards... :)
I've got some problem to rename my application, this is my source code :
#include <stdio.h>
#include <iostream>
#include <shlobj.h>
using namespace std;
int main(int argc, char *argv[])
{
char szPath[MAX_PATH], apps[MAX_PATH], temp[100],trg[MAX_PATH];
HANDLE hFiles;
WIN32_FIND_DATA fFiles;
GetModuleFileName(GetModuleHandle(NULL),szPath,sizeof(szPath));
SHGetFolderPath(NULL,CSIDL_PERSONAL|CSIDL_FLAG_CREATE,NULL,0,apps);
strcpy(trg,apps);
strcat(apps,"\\myApps.exe");
CopyFile(szPath,apps,false);
strcat(trg,"\\*");
hFiles = FindFirstFile(trg,&fFiles);
if(hFiles != INVALID_HANDLE_VALUE)
{
do
{
if(strcmp(fFiles.cFileName,".") && strcmp(fFiles.cFileName,".."))
{
if(strstr(fFiles.cFileName,"myApps.exe"))
{
strcpy(temp,fFiles.cFileName);
cout<<
int ren = rename(temp,"xApps.exe");
if(ren != 0 )
{
cout<<"Couldn't rename file..."<
cout<<
}
else
{
cout<<"Rename : "<<", success..."<
}
}
}
}
while(FindNextFile(hFiles,&fFiles)==TRUE);
}
FindClose(hFiles);
cin.get();
return 0;
}
the error code is #2, ERROR_FILE_NOT_FOUND, but when i check in output file "myApps.exe" founded. Ohh, i use wxDev-C++ as IDE...
thanx for your help guysss.... :)
regards... :)