|
We all are
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark Salsbery wrote: We all are
at least we never have to hold it for long!
_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
|
|
|
|
|
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Next time it's not gonna be easy man!
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
hello everyone,
i am facing the same problem... my text box variable are m_memid,m_memname, m_balance and m_date for thie i have to fix the cursor and text... how shall i do it please give some solutions please..as we do in VB like txtmemid.text and so on.. if i compile the program line by line then values are there in memory but they are not printing in the text boxes.. please help me out
THANKU IN ADVANCE,
savitri, 
|
|
|
|
|
Hi
In my programme VC++6.0 ATL COM, i used Com port Writing(output) through Com Port is done .But Reading(input) through Com port was not working Proberly.
Com Port Reading Function
OVERLAPPED comReader = { 0 };
BOOL fWaitingOnRead = FALSE;
char * lpBuf = "";
DWORD dwRead = 0; // bytes actually read
BOOL Success;
FILE* FilePtr;
DCB dcb = {0};
DWORD dwCommEvent;
COMMTIMEOUTS CommTimeOuts;
HANDLE hCommPort;
printf(" Inside CommThreadProc \n" );
//Opening the COM port
hCommPort = CreateFile( "COM1",GENERIC_READ,0,0,
OPEN_EXISTING,FILE_FLAG_OVERLAPPED, 0 );
if( hCommPort == INVALID_HANDLE_VALUE )
{ printf( "Error while Opening COM Port \n" );
return ;
}
//Getting COMM settings
GetCommState( hCommPort, &dcb );
dcb.BaudRate = CBR_9600;
dcb.ByteSize = 8;
dcb.Parity = NOPARITY;
dcb.StopBits = ONESTOPBIT;
SetCommState( hCommPort, &dcb );
//Creating overlapped event handle
comReader.hEvent = CreateEvent( NULL, TRUE, FALSE, NULL );
SetCommMask( hCommPort, EV_RXCHAR );
BOOL repeat = true;
while( 1 )
{ WaitCommEvent( hCommPort, &dwCommEvent, &comReader );
if( WaitForSingleObject( comReader.hEvent, INFINITE ) == WAIT_OBJECT_0 )
{ do
{ Success = ReadFile( hCommPort,&lpBuf,512,&dwRead,&comReader );
if( !Success )
if (GetLastError() == ERROR_IO_PENDING)
printf( "Error in reading the file \n");
else
{ // writing the data into a file
FilePtr = fopen( "comport.txt", "a+" );
if( FilePtr != NULL )
fwrite( &lpBuf, dwRead, 512, FilePtr );
else
printf( "Error while opening file" );
fclose( FilePtr );
}
}while( dwRead > 0 );
}
}
CloseHandle( comReader.hEvent );
CloseHandle( hCommPort );
In message box i receive something but mesage was blank.
i try to write the received data in to "comport.txt" file but it is not working.
I want to write the receving data in txt file,receving data was an character eg:"ff fe ".
thanks
by
shakumar
shakumar
modified on Friday, March 7, 2008 1:07 AM
|
|
|
|
|
(1) enclose code snippets int <pre> tags.
(2) the following line
shakumar_22 wrote: fwrite( &lpBuf, dwRead, 512, FilePtr );
is wrong: you're writing 512 times the amount of data you've read. Change it to:
fwrite( &lpBuf, 1, dwRead, FilePtr );
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Hi
i alter the code
fwrite( &,lpBuf, 1, dwRead, FilePtr );
even the data was not write in the Text file,only text file was creating with empty. In Debug mode it cross the Write file Line then also it was not written in file
thanks
shakumar
shakumar
|
|
|
|
|
usually according to the naming convention lpBuf is already a pointer to buffer , your usage of &lpBuf seems using the address of operator two times. What is the type of lpBuf?
|
|
|
|
|
Do you check (with the debugger) dwRead value?
As Rajkumar R suggested, probably you haven't to take lpBuff address. How is it declared?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
message was altered pls gothrough the modified message
thanks
shakumar
shakumar
|
|
|
|
|
Please give more info (i.e. what error message you get, if you get one; what is the dwRead value and so on).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
No error Message.
Text File was Creating but no data was writing.
dwRead value on Debug was "0"(zero).
shakumar
|
|
|
|
|
hey, what is this, "char * lpBuf = "";"
where is the buffer allocated to get the data read into it.
and you used fwrite(&lpBuf..), that is why you didn't get access violation.
as i suspected, you used address of operator on a pointer.
just for testing, try
char lpBuf[1024];
ReadFile(, lpBuf,..) not &lpBuf
fwrite(lpBuf,..) not &lpBuf
And you are not using the pointers correctly, join the "Book-Buying Band"[^], two already there.
|
|
|
|
|
After creating and switching into 2 to 3 desktops using CreateDesktop in Windows Vista we used the 3d flip state keys (windows key + tab key) to switch between active windows... it is not working... it works fine in windows xp but not in vista... (3d flip state is when many applications are opened we can toggle between active windows minimized 3d bars in the taskbar... when doing so you can see the toggling of the minimized state of all windows)... can anyone help us with this...
Today's Beautiful Moments are
Tomorrow's Beautiful Memories
|
|
|
|
|
I port my application in vc++ 2005 to vc++ 2008. it works proper other than registry entry code. Is this is bug of visual studio 2008?
|
|
|
|
|
Have you tried debugging? Did the registry function succeed? Did you checked the return value?
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Thanks for your replay.
It works in xp But shows problem in vista.
|
|
|
|
|
vicky00000 wrote: It works in xp But shows problem in vista.
I am sorry, I forgot my telescope today and am unable to see your monitor.
Can you please elaborate more on what the problem exactly is? How exactly are you dealing with the registry and what exactly does the registry function returns?
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Thanks for your replay.
I wrote an applcation in vc++ 2005,in which I create a new registry key and set some value. This one work proper in xp and vista. I port the same code to vc++ 2008. It works in xp, but not in vista.
I hope you can understand my problem.
Thanks.
|
|
|
|
|
vicky00000 wrote: I wrote an applcation in vc++ 2005,in which I create a new registry key and set some value. This one work proper in xp and vista. I port the same code to vc++ 2008. It works in xp, but not in vista.
Aren't you using some function which would create the new registry key? What is that function returning when you say it wasn't working?
vicky00000 wrote: I hope you can understand my problem.
I bet nobody can.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Thanks for ur replay.
long lRet = RegCreateKeyEx(HKEY_LOCAL_MACHINE,_T("Some Path"), 0, NULL,
REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hKey,
&dwDisposition);
lRet is 5 in the case vc++ 2008 and in the case vc++ 2005 lRet is 0
|
|
|
|
|
vicky00000 wrote: lRet is 5 in the case vc++ 2008 and in the case vc++ 2005 lRet is 0
The documentation for RegCreateEx says a non-zero value is returned, when the function fails. 5 is a non-zero value AFAIK.
The documentation also says: use FormatMessage()[^] with the FORMAT_MESSAGE_FROM_SYSTEM flag to get a generic description of the error.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
I would suspect it's an access denied error since you're writing to HKEY_LOCAL_MACHINE.
Your app needs to run with elevated privileges to do that.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark Salsbery,
Yes, this is access denied error, could you please explain how to overcome this problem.
Thanks in advance.
|
|
|
|