Click here to Skip to main content
15,891,777 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Why it is not good code for constructor Pin
George_George26-Dec-07 22:36
George_George26-Dec-07 22:36 
GeneralRe: Why it is not good code for constructor Pin
CPallini26-Dec-07 22:53
mveCPallini26-Dec-07 22:53 
GeneralRe: Why it is not good code for constructor Pin
George_George26-Dec-07 23:14
George_George26-Dec-07 23:14 
GeneralRe: Why it is not good code for constructor Pin
CPallini26-Dec-07 23:34
mveCPallini26-Dec-07 23:34 
GeneralRe: Why it is not good code for constructor Pin
George_George27-Dec-07 0:39
George_George27-Dec-07 0:39 
GeneralRe: Why it is not good code for constructor Pin
CPallini27-Dec-07 0:58
mveCPallini27-Dec-07 0:58 
GeneralRe: Why it is not good code for constructor Pin
George_George27-Dec-07 1:03
George_George27-Dec-07 1:03 
QuestionFile rename in UNICODE Pin
Ajay L D26-Dec-07 2:56
Ajay L D26-Dec-07 2:56 
Hi,
I am trying to rename a file. The new name of the file is present in another file. The problem is that the renamed file is having junk characters at the beginning. I opened the file in binary mode and found that the chars corresponded to 0xFF and 0xFE. Can anybody help me out?


Thanks!

The code I have is as follows:

{
int nRetCode = 0;

HANDLE fp = CreateFile(_T("KoreanIconNames.txt"), GENERIC_READ, FILE_SHARE_READ,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);

if(NULL != fp)
{
WCHAR str[BUFFER_SIZE] = {0,};
DWORD dwNumBytesRead = 0;
DWORD dwNumBytesWritten = 0;
size_t ret = 1;

ReadFile(fp, str, sizeof(str), &dwNumBytesRead, NULL);


HANDLE fpNew = CreateFile(_T("KoreanIconNamesNew.txt"), FILE_ALL_ACCESS, FILE_SHARE_READ, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);

if(NULL != fpNew)
{
WriteFile(fpNew, str, sizeof(str), &dwNumBytesWritten, NULL);

CloseHandle(fpNew);
}

// Rename the file
{
CFile fileRename;
WCHAR *pNewName = str;

pNewName = wcstok(str, _T("\n"));

if(NULL != pNewName)
{
CFile::Rename(_T("Citrix.lnk"), pNewName);
}
else
{
AfxMessageBox(_T("Could not tokenize the file name string") );
}
}

CloseHandle(fp);
}
}

AJ
GeneralRe: File rename in UNICODE [modified] Pin
Sarath C26-Dec-07 4:53
Sarath C26-Dec-07 4:53 
GeneralRe: File rename in UNICODE Pin
Ajay L D26-Dec-07 17:15
Ajay L D26-Dec-07 17:15 
GeneralRe: File rename in UNICODE Pin
CPallini26-Dec-07 4:56
mveCPallini26-Dec-07 4:56 
GeneralRe: File rename in UNICODE Pin
Ajay L D26-Dec-07 18:46
Ajay L D26-Dec-07 18:46 
GeneralRe: File rename in UNICODE Pin
David Crow27-Dec-07 4:32
David Crow27-Dec-07 4:32 
Generalbad_alloc Pin
George_George26-Dec-07 2:36
George_George26-Dec-07 2:36 
GeneralRe: bad_alloc Pin
CPallini26-Dec-07 11:53
mveCPallini26-Dec-07 11:53 
GeneralRe: bad_alloc Pin
George_George26-Dec-07 17:44
George_George26-Dec-07 17:44 
GeneralRe: bad_alloc Pin
CPallini26-Dec-07 20:58
mveCPallini26-Dec-07 20:58 
GeneralRe: bad_alloc Pin
George_George26-Dec-07 21:07
George_George26-Dec-07 21:07 
GeneralRe: bad_alloc Pin
CPallini26-Dec-07 21:27
mveCPallini26-Dec-07 21:27 
GeneralRe: bad_alloc Pin
George_George26-Dec-07 21:32
George_George26-Dec-07 21:32 
Questionhow am i use "textattr" which is library in turbo c to visual studio? Pin
Jung Seng Won26-Dec-07 2:12
Jung Seng Won26-Dec-07 2:12 
AnswerRe: how am i use "textattr" which is library in turbo c to visual studio? Pin
CPallini26-Dec-07 5:02
mveCPallini26-Dec-07 5:02 
GeneralRefreshing Tree control in VC++ Pin
CJ94200226-Dec-07 0:34
CJ94200226-Dec-07 0:34 
GeneralRe: Refreshing Tree control in VC++ Pin
peterchen26-Dec-07 0:45
peterchen26-Dec-07 0:45 
GeneralFile Handling Pin
Sangeetha_J25-Dec-07 22:52
Sangeetha_J25-Dec-07 22:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.