User Tools

Site Tools


check_medium

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

check_medium [2008/06/09 12:29] (current)
Line 1: Line 1:
 +====== Check for a inserted medium ======
 +
 +<​file>​This code snippet is originally from the former WinAPI site www.winapi.net</​file>​
 +
 +If you want to know, if the user inserted a medium like a disk or a CD into the drive, use this code:
 +
 +<code c>#​include <​windows.h>​
 +#include <​shlwapi.h>​
 +
 +// uDrive:
 +// 0 - A:\
 +// 1 - B:\
 +// 2 - C:\
 +// etc.
 +
 +BOOL IsDriveReady(UINT uDrive)
 +{
 +    TCHAR szRootPathName[32];​
 +    UINT uErrorMode;
 +    BOOL bRet;
 +
 +    PathBuildRoot(szRootPathName,​ uDrive);
 +
 +    uErrorMode = SetErrorMode(SEM_FAILCRITICALERRORS);​
 +    bRet = GetVolumeInformation(szRootPathName,​ NULL, 0, NULL, NULL, NULL, NULL, 0);
 +    SetErrorMode(uErrorMode);​
 +
 +    return(bRet);​
 +}</​code>​
  
check_medium.txt ยท Last modified: 2008/06/09 12:29 by christian