Click here to Skip to main content
15,913,210 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
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 
2buck56 wrote:
Does anyone know what I must do to eliminate the message from GetLastError?


First, CreateFile() is not a boolean function so checking its return value as such is wrong. Second, you need to call GetLastError() as soon as the error is detected, like:

DeviceHandle = CreateFile(detailData->DevicePath,
                          0,
                          FILE_SHARE_READ | FILE_SHARE_WRITE,
                          NULL,
                          OPEN_EXISTING,
                          0,
                          NULL);
  
if (DeviceHandle == INVALID_HANDLE_VALUE)
{
    LPVOID lpMsgBuf;
  
    FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
                  NULL,
                  GetLastError(),
                  MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
                  (LPTSTR) &lpMsgBuf,
                  0,
                  NULL);
    ...
    LocalFree(lpMsgBuf);
}


"One man's wage rise is another man's price increase." - Harold Wilson

"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons


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 
GeneralRe: Default path to Desktop with vista Pin
David Crow15-Jan-10 10:25
David Crow15-Jan-10 10:25 
GeneralRe: Default path to Desktop with vista Pin
dbell0715-Jan-10 10:46
dbell0715-Jan-10 10:46 
GeneralRe: Default path to Desktop with vista Pin
dbell0715-Jan-10 10:49
dbell0715-Jan-10 10:49 
GeneralRe: Default path to Desktop with vista Pin
Rozis16-Jan-10 10:28
Rozis16-Jan-10 10:28 
GeneralRe: Default path to Desktop with vista Pin
Spawn@Melmac18-Jan-10 0:35
Spawn@Melmac18-Jan-10 0:35 
QuestionShowing and Closing Dialogs in C++ Pin
NightBeforeChirstmas15-Jan-10 9:29
NightBeforeChirstmas15-Jan-10 9:29 
AnswerRe: Showing and Closing Dialogs in C++ Pin
Maximilien15-Jan-10 9:31
Maximilien15-Jan-10 9:31 
AnswerRe: Showing and Closing Dialogs in C++ Pin
David Crow15-Jan-10 9:48
David Crow15-Jan-10 9:48 
AnswerRe: Showing and Closing Dialogs in C++ Pin
Bram van Kampen17-Jan-10 6:35
Bram van Kampen17-Jan-10 6:35 
QuestionRetrieving Windows version, then enumerating process list Pin
int_8015-Jan-10 5:49
int_8015-Jan-10 5:49 
QuestionRe: Retrieving Windows version, then enumerating process list Pin
David Crow15-Jan-10 7:53
David Crow15-Jan-10 7:53 
AnswerRe: Retrieving Windows version, then enumerating process list Pin
CPallini15-Jan-10 11:06
mveCPallini15-Jan-10 11:06 
Questionhow to draw a graph on 2 axes in a window Pin
N Vamshi Krishna15-Jan-10 5:39
N Vamshi Krishna15-Jan-10 5:39 

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.