garbled output: Win32 : GetLogicalDriveStrings()

This is a discussion on garbled output: Win32 : GetLogicalDriveStrings() within the Windows Programming forums, part of the Platform Specific Boards category; why do i get garbled output from this: BOOL getLogicalNames(char *psDriveBuffer, DWORD nBufLen) { DWORD nRes; printf("Getting Logical Names\n"); if ...

  1. #1
    richgi
    Guest

    garbled output: Win32 : GetLogicalDriveStrings()

    why do i get garbled output from this:

    BOOL getLogicalNames(char *psDriveBuffer, DWORD nBufLen)
    {
    DWORD nRes;
    printf("Getting Logical Names\n");

    if ( (nRes = GetLogicalDriveStringsA (nBufLen, psDriveBuffer) )== 0 )
    return FALSE;
    else
    {
    printf("%d, %s", nRes, psDriveBuffer);
    return TRUE;
    }
    }

  2. #2
    Banned Troll_King's Avatar
    Join Date
    Oct 2001
    Posts
    1,784
    Post this kind of stuff on the Windows Programming Board.

  3. #3
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,856
    What length have you allocated to the psDriveBuffer?

    Are you using UNICODE (char is 2 bytes not one)?

    Is nRes > sizeof(psDriveBuffer) when function returns?

    What does GetLastError() return?

    (Is GetLogicalDriveStringsA() a typo? Should be GetLogicalDriveStrings() )

    I would get the return from the GetLogicalDriveStrings eg nRes and then test
    if((nRes<=0)||(nRes>sizeof(psDriveBuffer))
    {
    iError=GetLastError();
    sprintf(sBuffer,"GetLogicalDriveStringsA failed with error#%d.",iError);
    return FALSE;
    }
    else

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. code output...
    By roaan in forum C Programming
    Replies: 6
    Last Post: 07-03-2009, 02:22 AM
  2. Help for my output array
    By qwertysingh in forum C Programming
    Replies: 1
    Last Post: 02-17-2009, 02:08 PM
  3. execl()/fork() output
    By tadams in forum C Programming
    Replies: 19
    Last Post: 02-04-2009, 02:29 PM
  4. Trying to store system(command) Output
    By punxworm in forum C++ Programming
    Replies: 5
    Last Post: 04-20-2005, 06:46 PM
  5. OLE Clipboard :: Win32 API vs. MFC
    By kuphryn in forum Windows Programming
    Replies: 3
    Last Post: 08-11-2002, 05:57 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21