Click here to Skip to main content
15,920,704 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: WM_PAINT and WM_ERASEBKGND Pin
Javad Taheri (drjackool)8-Mar-15 6:06
Javad Taheri (drjackool)8-Mar-15 6:06 
GeneralRe: WM_PAINT and WM_ERASEBKGND Pin
Member 16192558-Mar-10 20:40
Member 16192558-Mar-10 20:40 
GeneralRe: WM_PAINT and WM_ERASEBKGND Pin
Nishad S8-Mar-10 22:02
Nishad S8-Mar-10 22:02 
QuestionAny way to start an application at bootup? Pin
ShaluMalu29-Jan-07 19:37
ShaluMalu29-Jan-07 19:37 
AnswerRe: Any way to start an application at bootup? Pin
Naveen29-Jan-07 20:34
Naveen29-Jan-07 20:34 
AnswerRe: Any way to start an application at bootup? Pin
Roger Stoltz29-Jan-07 21:43
Roger Stoltz29-Jan-07 21:43 
AnswerRe: Any way to start an application at bootup? Pin
James R. Twine30-Jan-07 1:23
James R. Twine30-Jan-07 1:23 
QuestionProblem with WriteFile Pin
amitmistry_petlad 29-Jan-07 19:14
amitmistry_petlad 29-Jan-07 19:14 
i have creating the file with WriteFile function.in the following way.

The File has created in the XML form.
but when i tried to open it in EXPLORER .
it gives me following error.


The XML page cannot be displayed
Cannot view XML input using style sheet. Please correct the error and then click the Refresh button, or try again later.


--------------------------------------------------------------------------------

An invalid character was found in text content. Error processing resource 'file:///D:/Encoder_user_siteid.xml'.

i am going to write file is following
----------------
<filelist><listitem type="file" order="0"><filename>C:\Documents and Settings\Amit\Desktop\MediaFiles\TT.wmv</filename><extension>wmv</extension><size>494 KB</size><Duration>00:00:38</Duration><Bitrate>103 Kbps</Bitrate><Type>Windows Media Audio/Video file</Type><modifydated>11/22/2005</modifydated></listitem></filelist>

//////////
actual display following in the edit mode.
-----------------------
ÌÌÌÌZ× ÌÌÌÌÌÌÌÌÌÌÌÌB" u" ÌÌÌÌÌÌÌÌ ÌÌÌÌÌÌÌÌ" ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ" ÌÌÌÌÌÌÌÌ / 2 2 / 2 0 0 5 i a A u d i o / V i d e o f i l e D e s k t o p \ M e d i a F i l e s \ T T . w m v ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ$«¥ôdæ ½(E àå ´B V Hæ µÙA ' ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌLÂE ÂE øÁE àÁE ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌð®¥ô æ ‡Ôw ' µÙA Í«ºÜ Hæ µÙA tæ ë‡ÔwµÙA  '


////////////////////////////////////


code for that is below (in short ,listview content is transfer in the xml file)
i am passing the listview handle to the _WriteXml function.

///////////////////////////////////////


void _WriteXml(HWND hList)
{
TCHAR buff[MAX_PATH];

LRESULT iCount=ListView_GetItemCount(hList);


size_t i,j;
string startstring;
for(i=0;i<iCount;i++) //for row
{

for(j=0;j<8;j++)//for column
{
ListView_GetItemText(hList,i,j,(LPWSTR)&buff,MAX_PATH);

std::wstring buff_input(buff);
if(j==0)
{
std::string bufferstrig(buff_input.begin(),buff_input.end());
string substring= bufferstrig.substr(bufferstrig.find_last_of("\\")+1,bufferstrig.length());
string addtag="\"\>";
char sub1[20];
sprintf(sub1,"%d",i);
string s=sub1;
if(substring=="")
startstring="<listitem type=\"dir\" order=\""+s;
else
startstring="<listitem type=\"file\" order=\""+s;

startstring+=addtag;
startstring=startstring+"<filename>"+bufferstrig+"</filename>";
}


if(j==1)
{
std::string bufferstrig(buff_input.begin(),buff_input.end());
string extension=bufferstrig;
startstring= startstring+"<extension>"+extension+"</extension>";
}


if(j==2)
{
std::string bufferstrig(buff_input.begin(),buff_input.end());
string size=bufferstrig;
startstring=startstring+ "<size>"+size+ "</size>";
}

if(j==3)
{
std::string bufferstrig(buff_input.begin(),buff_input.end());
string Duration=bufferstrig;
startstring=startstring+"<Duration>"+Duration+"</Duration>";
}

if(j==4)
{
std::string bufferstrig(buff_input.begin(),buff_input.end());
string Birarate =bufferstrig;
startstring=startstring+ "<Bitrate>"+ Birarate+ "</Bitrate>";
}

if(j==5)
{
std::string bufferstrig(buff_input.begin(),buff_input.end());
string Type=bufferstrig;
startstring=startstring+"<Type>"+Type+"</Type>";
}

if(j==6)
{
std::string bufferstrig(buff_input.begin(),buff_input.end());
string Modifdate=bufferstrig;
startstring=startstring+ "<modifydated>"+Modifdate+"</modifydated>";
}

/*if(j==7)
{
std::string bufferstrig(buff_input.begin(),buff_input.end());
string size=bufferstrig;
startstring=startstring+"<size>"+size+"<size>";
}*/
if(j==8)
{
std::string bufferstrig(buff_input.begin(),buff_input.end());
string Protected=bufferstrig;
startstring=startstring+ "<Protected>"+Protected +"</Protected>";
}
}
startstring=startstring+"</listitem>";
}

HANDLE hFile;
startstring="<filelist>"+startstring+"</filelist>";
hFile = CreateFile (_T("D:\\Encoder_user_siteid.xml"),GENERIC_WRITE, 0, NULL,CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL) ;
DWORD iBytesWritten=0;
BYTE amit =startstring.length();

bool hResult=WriteFile(hFile,&startstring,(amit+1)*sizeof(string),&iBytesWritten,NULL);
CloseHandle (hFile);

}

should i have to trim the startstring?
if so, then how do trim it i am tring to find the function, i had implement this with adding string.h
and iostream includes. e.g trim(startstring);
but function didn't work.

what should i do to see my xml file?
after wrting this file i hev to read this file.
i had found the problem with intial first charatcters might be take unicode or other.
so how i handle it.


























Best Regards
Amit.
AnswerRe: Problem with WriteFile Pin
Stephen Hewitt29-Jan-07 19:34
Stephen Hewitt29-Jan-07 19:34 
GeneralRe: Problem with WriteFile Pin
amitmistry_petlad 29-Jan-07 22:09
amitmistry_petlad 29-Jan-07 22:09 
GeneralRe: Problem with WriteFile Pin
David Crow30-Jan-07 2:30
David Crow30-Jan-07 2:30 
GeneralRe: Problem with WriteFile Pin
amitmistry_petlad 30-Jan-07 2:35
amitmistry_petlad 30-Jan-07 2:35 
QuestionRe: Problem with WriteFile Pin
David Crow30-Jan-07 2:43
David Crow30-Jan-07 2:43 
AnswerRe: Problem with WriteFile Pin
amitmistry_petlad 30-Jan-07 3:11
amitmistry_petlad 30-Jan-07 3:11 
GeneralRe: Problem with WriteFile Pin
David Crow30-Jan-07 3:29
David Crow30-Jan-07 3:29 
GeneralRe: Problem with WriteFile Pin
Stephen Hewitt30-Jan-07 11:34
Stephen Hewitt30-Jan-07 11:34 
GeneralRe: Problem with WriteFile Pin
amitmistry_petlad 30-Jan-07 16:47
amitmistry_petlad 30-Jan-07 16:47 
GeneralRe: Problem with WriteFile Pin
Stephen Hewitt30-Jan-07 16:54
Stephen Hewitt30-Jan-07 16:54 
GeneralRe: Problem with WriteFile Pin
amitmistry_petlad 30-Jan-07 18:00
amitmistry_petlad 30-Jan-07 18:00 
GeneralRe: Problem with WriteFile Pin
Stephen Hewitt30-Jan-07 18:07
Stephen Hewitt30-Jan-07 18:07 
GeneralRe: Problem with WriteFile Pin
amitmistry_petlad 30-Jan-07 18:58
amitmistry_petlad 30-Jan-07 18:58 
GeneralRe: Problem with WriteFile Pin
Stephen Hewitt30-Jan-07 19:24
Stephen Hewitt30-Jan-07 19:24 
GeneralRe: Problem with WriteFile Pin
amitmistry_petlad 30-Jan-07 19:47
amitmistry_petlad 30-Jan-07 19:47 
Questionfatal error C1001: INTERNAL COMPILER ERROR Pin
devvvy29-Jan-07 15:31
devvvy29-Jan-07 15:31 
AnswerRe: fatal error C1001: INTERNAL COMPILER ERROR Pin
Michael Dunn29-Jan-07 15:41
sitebuilderMichael Dunn29-Jan-07 15:41 

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.