drivemngr.h 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. #ifndef NULLSOFT_MLDISC_DRIVEMANAGER_HEADER
  2. #define NULLSOFT_MLDISC_DRIVEMANAGER_HEADER
  3. #if defined(_MSC_VER) && (_MSC_VER >= 1020)
  4. #pragma once
  5. #endif
  6. #include <windows.h>
  7. //#include "../primo/obj_primo.h"
  8. // drive types
  9. #define DRIVE_TYPE_UNKNOWN 0x00000000
  10. #define DRIVE_TYPE_CD 0x00000010
  11. #define DRIVE_TYPE_DVD 0x00000020
  12. #define DRIVE_CAP_UNKNOWN 0x80000000
  13. #define DRIVE_CAP_R 0x00010000
  14. #define DRIVE_CAP_RW 0x00020000
  15. #define DRIVE_CDR (DRIVE_TYPE_CD | DRIVE_CAP_R )
  16. #define DRIVE_CDRW (DRIVE_TYPE_CD | DRIVE_CAP_RW)
  17. #define DRIVE_DVDR (DRIVE_TYPE_DVD | DRIVE_CAP_R)
  18. #define DRIVE_DVDRW (DRIVE_TYPE_DVD | DRIVE_CAP_RW)
  19. #define DMW_DRIVEADDED 0x0001 // param contains drive letter
  20. #define DMW_DRIVEREMOVED 0x0002 // param contains drive letter
  21. #define DMW_DRIVECHANGED 0x0003 // param contains drive letter
  22. #define DMW_MEDIUMARRIVED 0x0004 // param contains drive letter
  23. #define DMW_MEDIUMREMOVED 0x0005 // param contains drive letter
  24. #define DMW_OPCOMPLETED 0x0006 // one of the async opetations completed
  25. #define DMW_MODECHANGED 0x0010 // LOWORD(param) = MAKEWORD(cLetter, cMode)
  26. typedef void* HDRVMNGR;
  27. typedef struct _DM_NOTIFY_PARAM DM_NOTIFY_PARAM;
  28. typedef void (CALLBACK *DMNPROC)(WORD/*wCode*/, INT_PTR/*param*/);
  29. typedef void (CALLBACK *DMFREEPROC)(DM_NOTIFY_PARAM *phdr);
  30. #define DM_EJECT_REMOVE 0
  31. #define DM_EJECT_LOAD 1
  32. #define DM_EJECT_CHANGE 2
  33. // valid with DM_UNITINFO_PARAM
  34. #define DMF_DESCRIPTION 0x00000001
  35. #define DMF_FIRMWARE 0x00000002
  36. #define DMF_READY 0x00000004
  37. // valid with DM_UNITINFO2_PARAM
  38. #define DMF_TYPES 0x00000001
  39. // valid with DM_DISCINFOEX_PARAM
  40. #define DMF_DRIVEMODE_DAO 0x00000000
  41. #define DMF_DRIVEMODE_TAO 0x00010000
  42. #define DMF_MEDIUMTYPE 0x00000001
  43. #define DMF_MEDIUMFORMAT 0x00000002
  44. #define DMF_TRACKS 0x00000004
  45. #define DMF_USED 0x00000008
  46. #define DMF_FREE 0x00000010
  47. // valid with DM_DISCINFO2_PARAM
  48. #define DMF_MEDIUM 0x00000001
  49. #define DMF_PROTECTEDDVD 0x00000002
  50. #define DMF_PACKETWRITTEN 0x00000004
  51. #define DMF_MEDIUMEX 0x00000008
  52. // valid with DM_FANCYTITLE_PARAM
  53. #define DMF_VOLUMELABEL 0x00000001 // volume label
  54. #define DMF_CDTEXT 0x00000002 // if set and medium inserted will try to get info from cdtext
  55. #define DMF_CDDB 0x00000004 // if set and medium inserted will try to get info from gracenote
  56. #define DMF_DRIVEDESCRIPTION 0x00000010 // will use PrimoSDK to get drive info
  57. // valid with DM_MCI_PARAM
  58. #define DMF_READY 0x00000004 //
  59. #define DMF_MEDIUMPRESENT 0x00000002 //
  60. #define DMF_MODE 0x00000001 //
  61. #define DMF_TRACKCOUNT 0x00000008 //
  62. #define DMF_TRACKSINFO 0x00000010 //
  63. #define DMF_MEDIUMUID 0x00000020 //
  64. #define DMF_MEDIUMUPC 0x00000040 //
  65. // valid with DM_IMAPI_PARAM
  66. #define DMF_BASEPNPID 0x00000001
  67. #define DMF_DISPLAYNAMES 0x00000002
  68. #define DMF_PATH 0x00000004
  69. #define DMF_DRIVESTATE 0x00000008
  70. #define DMF_DRIVETYPE 0x00000010
  71. #define DMF_QUERYMEDIATYPE 0x00000020
  72. #define DMF_QUERYMEDIAINFO 0x00000040
  73. // Operation Codes
  74. #define DMOP_GENERAL 0x0000
  75. #define DMOP_UNITINFO 0x0001
  76. #define DMOP_UNITINFO2 0x0002
  77. #define DMOP_DISCINFO 0x0003
  78. #define DMOP_DISCINFO2 0x0004
  79. #define DMOP_TITLE 0x0005
  80. #define DMOP_MCIINFO 0x0006
  81. #define DMOP_IMAPIINFO 0x0007
  82. // Drive modes
  83. #define DM_MODE_ERROR ((CHAR)(0 - 1))
  84. #define DM_MODE_READY 0x00
  85. #define DM_MODE_BURNING 0x01
  86. #define DM_MODE_RIPPING 0x02
  87. #define DM_MODE_COPYING 0x03
  88. typedef struct _DM_NOTIFY_PARAM
  89. {
  90. INT_PTR callback; // pointer to the callback. If uMsg != 0 callback is HWND, otherwise it is DMNPROC
  91. UINT uMsg; // specify message code to post notification. if 0 callback points to DMNPROC.
  92. CHAR cLetter; // drive letter.
  93. UINT fFlags; // DMF_XXX
  94. DWORD result; // result code. Set by async func.
  95. WORD opCode; // completed opCode (DMOP_XXX). Set by async func.
  96. DMFREEPROC fnFree; // you can specify function that need to be called to free data
  97. HANDLE hReserved; // reserved;
  98. } DM_NOTIFY_PARAM;
  99. typedef struct _DM_UNITINFO_PARAM
  100. {
  101. DM_NOTIFY_PARAM header;
  102. DWORD dwType; // unit type
  103. BOOL bReady; // unit ready flag
  104. LPSTR pszDesc; // pointer to the buffer with unit description.
  105. INT cchDesc; // [in] length of the decription buffer in chars. [out] number of characters written. If error value is negative and show minimum required buffer
  106. LPSTR pszFirmware; // pointer to the buffer with FirmWare ( firmware version is always 4 chars)
  107. INT cchFirmware; // [in] length of the firmware buffer in chars. [out] number of characters written. If error value is negative and show minimum required buffer
  108. } DM_UNITINFO_PARAM;
  109. typedef struct _DM_UNITINFO2_PARAM
  110. {
  111. DM_NOTIFY_PARAM header;
  112. DWORD *pdwTypes; // unit types vector
  113. INT nTypes; // vector length (in DWORDS)
  114. DWORD dwClassId; // class identifier assigned to the unit.
  115. DWORD dwBusType; // type of bus to which the device is connected.
  116. } DM_UNITINFO2_PARAM;
  117. typedef struct _DM_DISCINFOEX_PARAM
  118. {
  119. DM_NOTIFY_PARAM header;
  120. DWORD dwMediumType; // type of the medium.
  121. DWORD dwMediumFormat; // format of the media
  122. BOOL bErasable; //
  123. DWORD dwTracks; // number of tracks in the disc.
  124. DWORD dwUsed; // total number of sectors used on the disc.
  125. DWORD dwFree; // total number of free sectors on the disc.
  126. } DM_DISCINFOEX_PARAM;
  127. typedef struct _DM_DISCINFO2_PARAM
  128. {
  129. DM_NOTIFY_PARAM header;
  130. DWORD dwMedium; // physical type of the media.
  131. BOOL bProtectedDVD; // DVD containing copy-protected content.
  132. BOOL bPacketWritten; // if the media is formatted by packet writing software.
  133. DWORD dwMediumEx; // physical type of the medium.
  134. } DM_DISCINFO2_PARAM;
  135. typedef struct _DM_TITLE_PARAM
  136. {
  137. DM_NOTIFY_PARAM header;
  138. LPWSTR pszTitle;
  139. INT cchTitle;
  140. } DM_TITLE_PARAM;
  141. typedef struct _DM_MCI_PARAM
  142. {
  143. DM_NOTIFY_PARAM header;
  144. BOOL bReady;
  145. BOOL bMediumPresent;
  146. UINT uMode;
  147. DWORD* pTracks; // this contains track info (first bit set to '1' if track is audio, other bits track length
  148. INT nTracks;
  149. LPWSTR pszMediumUID;
  150. INT cchMediumUID;
  151. LPWSTR pszMediumUPC;
  152. INT cchMediumUPC;
  153. } DM_MCI_PARAM;
  154. // you responsible for freeing all bstrs (use SysFreeString())
  155. typedef struct _DM_IMAPI_PARAM
  156. {
  157. DM_NOTIFY_PARAM header; // header result contains HRESULT
  158. BOOL bRecorder; // Set to TRUE if IMAPI fond drive
  159. BSTR bstrBasePnPID; // DMF_BASEPNPID
  160. BSTR bstrVendorID; // DMF_DISPLAYNAMES
  161. BSTR bstrProductID; // DMF_DISPLAYNAMES
  162. BSTR bstrRevision; // DMF_DISPLAYNAMES
  163. BSTR bstrPath; // DMF_PATH
  164. ULONG ulDriveState; // DMF_DRIVESTATE
  165. LONG fDriveType; // DMF_DRIVETYPE
  166. LONG fMediaType; // DMF_QUERYMEDIATYPE
  167. LONG fMediaFlags; // DMF_QUERYMEDIATYPE
  168. BYTE bSessions; // DMF_QUERYMEDIAINFO
  169. BYTE bLastTrack; // DMF_QUERYMEDIAINFO
  170. ULONG ulStartAddress; // DMF_QUERYMEDIAINFO
  171. ULONG ulNextWritable; // DMF_QUERYMEDIAINFO
  172. ULONG ulFreeBlocks; // DMF_QUERYMEDIAINFO
  173. } DM_IMAPI_PARAM;
  174. BOOL DriveManager_Initialize(DMNPROC DMNProc, BOOL bSuspended);
  175. BOOL DriveManager_Uninitialize(INT msExitWaitTime);
  176. BOOL DriveManager_Suspend(void);
  177. BOOL DriveManager_Resume(BOOL bUpdate);
  178. INT DriveManager_GetDriveList(CHAR *pLetters, INT cchSize);
  179. BOOL DriveManager_Update(BOOL bAsync); // check all drives and discs
  180. BOOL DriveManager_SetDriveMode(CHAR cLetter, CHAR cMode);
  181. CHAR DriveManager_GetDriveMode(CHAR cLetter);
  182. DWORD DriveManager_GetDriveType(CHAR cLetter);
  183. BOOL DriveManager_Eject(CHAR cLetter, INT nCmd); // nCmd = DM_EJECT_XXX
  184. BOOL DriveManager_IsUnitReady(BOOL *pbReady);
  185. BOOL DriveManager_IsMediumInserted(CHAR cLetter);
  186. // PrimoSDK async calls
  187. BOOL DriveManager_GetUnitInfo(DM_UNITINFO_PARAM *puip);
  188. BOOL DriveManager_GetUnitInfo2(DM_UNITINFO2_PARAM *puip);
  189. BOOL DriveManager_GetDiscInfoEx(DM_DISCINFOEX_PARAM *pdip);
  190. BOOL DriveManager_GetDiscInfo2(DM_DISCINFO2_PARAM *pdip);
  191. BOOL DriveManager_QueryTitle(DM_TITLE_PARAM *pdtp);
  192. // MCI async
  193. BOOL DriveManager_GetMCIInfo(DM_MCI_PARAM *pmcip);
  194. //IMAPI async
  195. BOOL DriveManager_GetIMAPIInfo(DM_IMAPI_PARAM *pIMAPI);
  196. #endif //NULLSOFT_MLDISC_DRIVEMANAGER_HEADER