|
This is not a good way to check if a thread has exited. Here’s what MSDN has to say on this issue:
Warning: If a thread happens to return STILL_ACTIVE (259) as an error code, applications that test for this value could end up in an infinite loop.
Here's how you do it without such dangers:
if (WaitForSingleObject(hThread, 0)==WAIT_OBJECT_0)
{
}
Don't forget to close the thread handle when you're done with it.
Steve
|
|
|
|
|
i need some information about programing for usb port
|
|
|
|
|
Ok see here[^] for some info and also wikipedia has some good info here[^]
|
|
|
|
|
mahieh wrote: i need some information about programing for usb port
Open the driver associated with the USB device withe the CreateFile function and then you can use ReadFile or WriteFile to read or write data. You can also use DeviceIOControl to exchange driver specific commands.
|
|
|
|
|
I want to calculate the mode(statistics) of the data items stored in vector
|
|
|
|
|
PREETIGUPTA wrote: the mode(statistics)
What do you mean by mode exactly ? (I don't remember having learned something like that in statistic...)
PREETIGUPTA wrote: data items
What kind of data ?
PREETIGUPTA wrote: in vector
A std::vector ? Or a plain C++ array ?
Also, try to use a relevant title. I don't really see how your question is related to Visual C++ (or, yes, I see but in that case ALL questions could have the same title).
|
|
|
|
|
Cedric Moonen wrote: PREETIGUPTA wrote:
the mode(statistics)
What do you mean by mode exactly ? (I don't remember having learned something like that in statistic...)
He means this:
Mode (statistics)[^]
If the vector contains discrete values (integers), then the problem is just to find the most commonly occurring value.
|
|
|
|
|
|
|
|
|
Hello all,
When I tried to compile my program, I am having following error. If you know how to resolve please help me.
Linking...
mfcs42d.lib(stdafx.obj) : error : Internal error during Pass2
ExceptionCode = C0000005
ExceptionFlags = 00000000
ExceptionAddress = 1030C9DE
NumberParameters = 00000002
ExceptionInformation[ 0] = 00000000
ExceptionInformation[ 1] = 00000014
CONTEXT:
Eax = 00000000 Esp = 0012F0B0
Ebx = 00377DD0 Ebp = 0012F0C0
Ecx = 00000000 Esi = 00377DD0
Edx = 00001003 Edi = 00001003
Eip = 1030C9DE EFlags = 00010256
SegCs = 0000001B SegDs = 00000023
SegSs = 00000023 SegEs = 00000023
SegFs = 0000003B SegGs = 00000000
Dr0 = 0012F0B0 Dr3 = 00377DD0
Dr1 = 0012F0C0 Dr6 = 00000000
Dr2 = 00000000 Dr7 = 00000000
Error executing link.exe.
Tool execution canceled by user.
Thanks for ur prompt reply.
Regards,
Nikhs
Nikhil Trivedi
|
|
|
|
|
|
I am using Visual Studio 6.0. Can I use the link you provided for VS.net 2002 ? Let me know at the earliest please.
Thanks for the reply.
Regards,
Nikhs
Nikhil Trivedi
|
|
|
|
|
I dont think you can use that, but you can give a try.
You can try other things like - make sure you dont have any whitespaces in yout temp/tmp directory names.
- make sure that you dont have any whitespaces in your object(.obj) file names
- make sure you are using link.exe that you think you are using
Cheers
|
|
|
|
|
Hi,
I've have a file which is written during a program and it is written by using myfile.write(string,string.GetLength()+1);
myfile is a temporary file where user may attempt to save it by clicking 'Save' button. However, i got one example on 'OnSave() function which i don't quite understand to use it.
void MyDlg::OnSave()
{
UpdateData();
GetBufferSize();
OPENFILENAME openfile;
openfile.lStructSize=sizeof(OPENFILENAME) ;
openfile.hwndOwner=AfxGetApp()->m_pMainWnd->m_hWnd;
openfile.lpstrFilter="Text Files (.txt)\0*.txt\0";
openfile.lpstrInitialDir=m_binfile;
openfile.lpstrTitle="Save Buffer";
openfile.lpstrCustomFilter=NULL;
// Set default file type in open file dialog
CString ext=m_binfile.Right(3);
ext.MakeUpper();
openfile.nFilterIndex=1;
CString filename="Result File";
filename=filename.Mid(filename.ReverseFind('\\')+1);
filename=filename.Left(filename.ReverseFind('.'));
char file[MAX_PATH];
file[0]=0;
strcpy(file,filename);
openfile.lpstrFile=file;
openfile.nMaxFile=MAX_PATH;
openfile.lpstrFileTitle=NULL;
openfile.Flags=OFN_HIDEREADONLY;
openfile.nFileOffset=0;
openfile.nFileExtension=0;
openfile.lpstrDefExt=ext;
openfile.lCustData=0;
if (!GetSaveFileName(&openfile))
return;
filename=file;
// Update file type selection
ext=filename.Right(3);
ext.MakeUpper();
// Saving buffer as binary file
HANDLE hFile=CreateFile(filename,GENERIC_WRITE,
FILE_SHARE_WRITE,
NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
if (hFile==INVALID_HANDLE_VALUE)
{
m_status.Format(_T("Failed to save buffer!"));
UpdateData(FALSE);
MessageBox(_T("Failed to save buffer!"));
return;
}
// Save file
DWORD bytewrite;
SetFilePointer(hFile,0,0,FILE_BEGIN);
WriteFile(hFile,m_buffer,m_filesize,&bytewrite,NULL);
SetEndOfFile(hFile);
CloseHandle(hFile);
m_status.Format(_T("Buffer saved successfully."));
UpdateData(FALSE);
}
However is there any example that i can refer that allows myfile.txt to be saved in the chosen location after clicking 'Save'?
Thanks for any replies
|
|
|
|
|
It's simple;
<br />
CString str = "... this is the file content to be saved ...";<br />
<br />
CFile f;<br />
if (f.Open("C:\\myFile.txt", CFile::modeCreate | CFile::modeWrite))<br />
{<br />
f.Write(str, str .GetLength());<br />
}<br />
--
======
Arman
|
|
|
|
|
void CfilelistDlg::OnBnClickedCancel()<br />
{<br />
CString col1,col2;<br />
CString str,load;<br />
load="cool.xls";<br />
CFile myFile1(load, CFile::modeReadWrite);<br />
CArchive arStore(&myFile1, CArchive::store);<br />
myFile1.SeekToBegin();<br />
count=m_ctrlfile.GetItemCount();<br />
while(count!=0)<br />
{<br />
col1=m_ctrlfile.GetItemText(count-1,0);<br />
col2=m_ctrlfile.GetItemText(count-1,1);<br />
arStore.WriteString(col1);<br />
load="\t";<br />
arStore.WriteString(load);<br />
<br />
arStore.WriteString(col2);<br />
load="\n";<br />
arStore.WriteString(load);<br />
count--;<br />
}<br />
arStore.Close();<br />
OnCancel();<br />
}
see this article
here an excel file is used you can change it to txt.
as the data is loaded on the list control you can load it on a edit box or on any thing else. And when the user clicks the save button you can load the data again on the file, replacing the previous data
|
|
|
|
|
You can use of
void CfilelistDlg::OnBnClickedCancel()
{
...
...
instead
<br />
void CfilelistDlg::OnBnClickedCancel()<br />
{<br />
...<br />
...<br />
Chris Maunder said :
"If you are posting source code with your question, place it inside pre /pre tags"
|
|
|
|
|
thanx will do it next time
|
|
|
|
|
Thank you
|
|
|
|
|
hi..
can anyone tell what are the parameters to be passed to initialize RIL API to get notifications on incoming call.
this is the function i hav used..but it does not initialize successfully..
HRESULT RIL_Initialize(1,NULL,Notif,RIL_NOTIFY_CONNECT|RIL_NOTIFY_DISCONNECT, NULL, NULL);
thanx
|
|
|
|
|
Hi, I need to use XmlDocument in C++, do I have to use managed c++? If not, what header files do I have to include? Thanks!
Nathan
|
|
|
|
|
No, you don't need to use managed C++. See this[^] link for MSXML examples. Personally, I prefer to use TinyXML[^]. (It doesn't do everything MSXML does, but what it does, it does well.)
/ravi
|
|
|
|
|
Hello,
I am using the MFC archive mechanism (serialize) to write out my document data. So I have something like:
void MyDoc::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
ar << somedata;
}
else
{
ar >> somedata;
}
}
How do I attach an icon to the file I have written out?
Thank you!
Max
|
|
|
|