Home > Citrix, Debugging > GetLasterror and OutputDebugString

GetLasterror and OutputDebugString

 

How to capture the output of GetLastError using OutputDebugString ?  Because GLE returns a DWORD, OutputDebugString doesn’t seem to like the input.

Put this on next line of the function that is returning the value: -

=============================================
DWORD dwErr = GetLastError();
char Buffer[MAX_PATH+1] = {0};
sprintf_s(Buffer,  MAX_PATH, “Last Err 0x%x\n”, dwErr);
OutputDebugStringA(Buffer);
=============================================

if any other function calls between then buffer holding info will be lost, so you may not get the correct value: – Below is one the example related ScardEstablishedContext()…

DWORD drREt = ScardEstablishedContext(…..);
DWORD dwErr = GetLastError();
char Buffer[MAX_PATH+1] = {0};
sprintf_s(Buffer,  MAX_PATH, “Last Err 0x%x\n”, dwErr);
OutputDebugStringA(Buffer);

  1. No comments yet.
  1. No trackbacks yet.