Click here to Skip to main content
15,885,869 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: CButton GetState , how to read the press and hold state of a button? Pin
timbk16-Jan-10 11:18
timbk16-Jan-10 11:18 
AnswerRe: CButton GetState , how to read the press and hold state of a button? Pin
Rozis16-Jan-10 10:17
Rozis16-Jan-10 10:17 
Questionsystem call too small Pin
2buck5615-Jan-10 10:36
2buck5615-Jan-10 10:36 
AnswerRe: system call too small Pin
CPallini15-Jan-10 10:44
mveCPallini15-Jan-10 10:44 
GeneralRe: system call too small Pin
2buck5615-Jan-10 11:36
2buck5615-Jan-10 11:36 
GeneralRe: system call too small Pin
LunaticFringe15-Jan-10 11:44
LunaticFringe15-Jan-10 11:44 
GeneralRe: system call too small Pin
2buck5615-Jan-10 12:26
2buck5615-Jan-10 12:26 
GeneralRe: system call too small Pin
Garth J Lancaster15-Jan-10 12:49
professionalGarth J Lancaster15-Jan-10 12:49 
The most likely cause is the FormatMessage call - I see you're using FORMAT_MESSAGE_ALLOCATE_BUFFER and a Size of 0

From MSDN "If FORMAT_MESSAGE_ALLOCATE_BUFFER is set, this parameter specifies the minimum number of TCHARs to allocate for an output buffer.

so you arnt supplying it with a minimum number of characters

.. so maybe this is what is producing the message - but as the others have already pointed out, to call DisplayLastError() if the call to CreateFile actually succeeeded is pointless anyway.

I think your DisplayLastError() function is incorrect if you intend calling it unnecessarily like this - but if you insist, you could call and store the result from GetLastError() in a DWORD, then test the stored value to see if it's 0 (zero) or not, if it is 0, then you can actually return/exit DisplayLastError or set a hardcoded string eg 'No Error'. If it's NOT 0, then you use the stored value, do the FormatMEssage etc

'g'
GeneralRe: system call too small Pin
LunaticFringe15-Jan-10 13:01
LunaticFringe15-Jan-10 13:01 
GeneralRe: system call too small Pin
2buck5615-Jan-10 13:51
2buck5615-Jan-10 13:51 
GeneralRe: system call too small [modified] Pin
LunaticFringe15-Jan-10 14:31
LunaticFringe15-Jan-10 14:31 
GeneralRe: system call too small Pin
2buck5615-Jan-10 15:02
2buck5615-Jan-10 15:02 
GeneralRe: system call too small Pin
CPallini15-Jan-10 22:02
mveCPallini15-Jan-10 22:02 
GeneralRe: system call too small Pin
CPallini15-Jan-10 22:11
mveCPallini15-Jan-10 22:11 
GeneralRe: system call too small Pin
Garth J Lancaster15-Jan-10 22:41
professionalGarth J Lancaster15-Jan-10 22:41 
GeneralRe: system call too small Pin
CPallini15-Jan-10 22:43
mveCPallini15-Jan-10 22:43 
GeneralRe: system call too small Pin
Garth J Lancaster15-Jan-10 22:59
professionalGarth J Lancaster15-Jan-10 22:59 
GeneralRe: system call too small Pin
CPallini15-Jan-10 23:10
mveCPallini15-Jan-10 23:10 
GeneralRe: system call too small Pin
Bram van Kampen17-Jan-10 6:18
Bram van Kampen17-Jan-10 6:18 
AnswerRe: system call too small Pin
Richard MacCutchan15-Jan-10 23:55
mveRichard MacCutchan15-Jan-10 23:55 
AnswerRe: system call too small Pin
David Crow16-Jan-10 5:06
David Crow16-Jan-10 5:06 
GeneralRe: system call too small Pin
CPallini16-Jan-10 7:57
mveCPallini16-Jan-10 7:57 
GeneralRe: system call too small Pin
2buck5616-Jan-10 11:01
2buck5616-Jan-10 11:01 
QuestionDefault path to Desktop with vista Pin
dbell0715-Jan-10 9:52
dbell0715-Jan-10 9:52 
AnswerRe: Default path to Desktop with vista Pin
CoderGirl4215-Jan-10 10:18
CoderGirl4215-Jan-10 10:18 

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.