aboutsummaryrefslogtreecommitdiff
path: root/Src/Plugins/Library/ml_disc/drivemngr.h
blob: c5e9c2e974fa0b241378fe8bf4e7d2201b86744a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
#ifndef NULLSOFT_MLDISC_DRIVEMANAGER_HEADER
#define NULLSOFT_MLDISC_DRIVEMANAGER_HEADER

#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif

#include <windows.h>
//#include "../primo/obj_primo.h"

// drive types

#define DRIVE_TYPE_UNKNOWN		0x00000000
#define DRIVE_TYPE_CD			0x00000010
#define DRIVE_TYPE_DVD			0x00000020
#define DRIVE_CAP_UNKNOWN		0x80000000
#define DRIVE_CAP_R				0x00010000
#define DRIVE_CAP_RW				0x00020000
#define DRIVE_CDR			(DRIVE_TYPE_CD | DRIVE_CAP_R )
#define DRIVE_CDRW			(DRIVE_TYPE_CD | DRIVE_CAP_RW)
#define DRIVE_DVDR			(DRIVE_TYPE_DVD | DRIVE_CAP_R)
#define DRIVE_DVDRW			(DRIVE_TYPE_DVD | DRIVE_CAP_RW)

#define DMW_DRIVEADDED			0x0001	// param contains drive letter
#define DMW_DRIVEREMOVED			0x0002	// param contains drive letter
#define DMW_DRIVECHANGED			0x0003  // param contains drive letter
#define DMW_MEDIUMARRIVED		0x0004	// param contains drive letter
#define DMW_MEDIUMREMOVED		0x0005	// param contains drive letter
#define DMW_OPCOMPLETED			0x0006	// one of the async opetations completed

#define DMW_MODECHANGED			0x0010	// LOWORD(param) = MAKEWORD(cLetter, cMode) 

typedef void* HDRVMNGR;

typedef struct _DM_NOTIFY_PARAM DM_NOTIFY_PARAM;

typedef void (CALLBACK *DMNPROC)(WORD/*wCode*/, INT_PTR/*param*/);
typedef void (CALLBACK *DMFREEPROC)(DM_NOTIFY_PARAM *phdr);


#define DM_EJECT_REMOVE	0
#define DM_EJECT_LOAD	1
#define DM_EJECT_CHANGE	2

// valid with DM_UNITINFO_PARAM
#define DMF_DESCRIPTION		0x00000001
#define DMF_FIRMWARE		0x00000002
#define DMF_READY			0x00000004

// valid with DM_UNITINFO2_PARAM
#define DMF_TYPES			0x00000001

// valid with DM_DISCINFOEX_PARAM
#define DMF_DRIVEMODE_DAO	0x00000000
#define DMF_DRIVEMODE_TAO	0x00010000
#define DMF_MEDIUMTYPE		0x00000001
#define DMF_MEDIUMFORMAT	0x00000002
#define DMF_TRACKS			0x00000004
#define DMF_USED			0x00000008
#define DMF_FREE			0x00000010

// valid with DM_DISCINFO2_PARAM
#define DMF_MEDIUM			0x00000001
#define DMF_PROTECTEDDVD	0x00000002
#define DMF_PACKETWRITTEN	0x00000004
#define DMF_MEDIUMEX		0x00000008

// valid with DM_FANCYTITLE_PARAM
#define DMF_VOLUMELABEL		0x00000001	// volume label 
#define DMF_CDTEXT			0x00000002	// if set and medium inserted will try to get info from cdtext
#define DMF_CDDB			0x00000004  // if set and medium inserted will try to get info from gracenote
#define DMF_DRIVEDESCRIPTION	0x00000010	// will use PrimoSDK to get drive info 

// valid with DM_MCI_PARAM
#define DMF_READY			0x00000004	// 
#define DMF_MEDIUMPRESENT	0x00000002	// 
#define DMF_MODE			0x00000001  // 
#define DMF_TRACKCOUNT		0x00000008	// 
#define DMF_TRACKSINFO		0x00000010	// 
#define DMF_MEDIUMUID		0x00000020	// 
#define DMF_MEDIUMUPC		0x00000040	// 

// valid with DM_IMAPI_PARAM
#define DMF_BASEPNPID		0x00000001
#define DMF_DISPLAYNAMES	0x00000002
#define DMF_PATH			0x00000004
#define DMF_DRIVESTATE		0x00000008
#define DMF_DRIVETYPE		0x00000010
#define DMF_QUERYMEDIATYPE	0x00000020
#define DMF_QUERYMEDIAINFO	0x00000040


// Operation Codes
#define DMOP_GENERAL		0x0000
#define DMOP_UNITINFO		0x0001
#define DMOP_UNITINFO2		0x0002
#define DMOP_DISCINFO		0x0003
#define DMOP_DISCINFO2		0x0004
#define DMOP_TITLE			0x0005
#define DMOP_MCIINFO		0x0006
#define DMOP_IMAPIINFO		0x0007

// Drive modes
#define DM_MODE_ERROR		((CHAR)(0 - 1))

#define DM_MODE_READY		0x00
#define DM_MODE_BURNING		0x01
#define DM_MODE_RIPPING		0x02
#define DM_MODE_COPYING		0x03


typedef struct _DM_NOTIFY_PARAM
{
	INT_PTR		callback;	// pointer to the callback. If uMsg != 0 callback is HWND, otherwise it is DMNPROC
	UINT		uMsg;		// specify message code to post notification. if 0 callback points to DMNPROC.
	CHAR		cLetter;	// drive letter.
	UINT		fFlags;		// DMF_XXX
	DWORD		result;		// result code. Set by async func.
	WORD		opCode;		// completed opCode (DMOP_XXX). Set by async func.
	DMFREEPROC	fnFree;		// you can specify function that need to be called to free data
	HANDLE		hReserved;	// reserved;
} DM_NOTIFY_PARAM;


typedef struct _DM_UNITINFO_PARAM 
{
	DM_NOTIFY_PARAM	header;
    DWORD		dwType;		// unit type
	BOOL		bReady;		// unit ready flag
	LPSTR		pszDesc;	// pointer to the buffer with unit description.
	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
	LPSTR		pszFirmware;	// pointer to the buffer with FirmWare ( firmware version is always 4 chars)
	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
} DM_UNITINFO_PARAM;

typedef struct _DM_UNITINFO2_PARAM 
{
	DM_NOTIFY_PARAM	header;
	DWORD		*pdwTypes;	// unit types vector
	INT			nTypes;		// vector length (in DWORDS)
	DWORD		dwClassId;	// class identifier assigned to the unit.
	DWORD		dwBusType;	// type of bus to which the device is connected.
} DM_UNITINFO2_PARAM;


typedef struct _DM_DISCINFOEX_PARAM 
{
	DM_NOTIFY_PARAM	header;
	DWORD		dwMediumType;	// type of the medium.
	DWORD		dwMediumFormat;	// format of the media
	BOOL		bErasable;		// 
	DWORD		dwTracks;		// number of tracks in the disc.
	DWORD		dwUsed;			// total number of sectors used on the disc.
	DWORD		dwFree;			// total number of free sectors on the disc.

} DM_DISCINFOEX_PARAM;

typedef struct _DM_DISCINFO2_PARAM 
{
	DM_NOTIFY_PARAM	header;
	DWORD		dwMedium;		// physical type of the media.
	BOOL		bProtectedDVD;	// DVD containing copy-protected content.
	BOOL		bPacketWritten;	// if the media is formatted by packet writing software.
	DWORD		dwMediumEx;		// physical type of the medium.
} DM_DISCINFO2_PARAM;


typedef struct _DM_TITLE_PARAM
{
	DM_NOTIFY_PARAM	header;
	LPWSTR			pszTitle;
	INT				cchTitle;

} DM_TITLE_PARAM;

typedef struct _DM_MCI_PARAM
{
	DM_NOTIFY_PARAM header;
	BOOL			bReady;	
	BOOL			bMediumPresent;
	UINT			uMode;
	DWORD*			pTracks;	// this contains track info (first bit set to '1' if track is audio, other bits track length
	INT				nTracks;
	LPWSTR			pszMediumUID;
	INT				cchMediumUID;
	LPWSTR			pszMediumUPC;
	INT				cchMediumUPC;
} DM_MCI_PARAM;

// you responsible for freeing all bstrs (use SysFreeString())
typedef struct _DM_IMAPI_PARAM
{
	DM_NOTIFY_PARAM header;		// header result contains HRESULT
	BOOL	bRecorder;			// Set to TRUE if IMAPI fond drive
	BSTR	bstrBasePnPID;		// DMF_BASEPNPID
	BSTR	bstrVendorID;		// DMF_DISPLAYNAMES	
	BSTR	bstrProductID;		// DMF_DISPLAYNAMES	
	BSTR	bstrRevision;		// DMF_DISPLAYNAMES	
	BSTR	bstrPath;			// DMF_PATH
	ULONG	ulDriveState;		// DMF_DRIVESTATE
	LONG	fDriveType;			// DMF_DRIVETYPE
	LONG	fMediaType;			// DMF_QUERYMEDIATYPE
	LONG	fMediaFlags;		// DMF_QUERYMEDIATYPE
	BYTE	bSessions;			// DMF_QUERYMEDIAINFO
	BYTE	bLastTrack;			// DMF_QUERYMEDIAINFO
	ULONG	ulStartAddress;		// DMF_QUERYMEDIAINFO
	ULONG	ulNextWritable;		// DMF_QUERYMEDIAINFO
	ULONG	ulFreeBlocks;		// DMF_QUERYMEDIAINFO

} DM_IMAPI_PARAM;

BOOL DriveManager_Initialize(DMNPROC DMNProc, BOOL bSuspended);
BOOL DriveManager_Uninitialize(INT msExitWaitTime);
BOOL DriveManager_Suspend(void);
BOOL DriveManager_Resume(BOOL bUpdate);
INT DriveManager_GetDriveList(CHAR *pLetters, INT cchSize);
BOOL DriveManager_Update(BOOL bAsync);		// check all drives and discs
BOOL DriveManager_SetDriveMode(CHAR cLetter, CHAR cMode); 
CHAR DriveManager_GetDriveMode(CHAR cLetter);
DWORD DriveManager_GetDriveType(CHAR cLetter);
BOOL DriveManager_Eject(CHAR cLetter, INT nCmd); // nCmd = DM_EJECT_XXX
BOOL DriveManager_IsUnitReady(BOOL *pbReady);
BOOL DriveManager_IsMediumInserted(CHAR cLetter);
// PrimoSDK async calls
BOOL DriveManager_GetUnitInfo(DM_UNITINFO_PARAM *puip);
BOOL DriveManager_GetUnitInfo2(DM_UNITINFO2_PARAM *puip);
BOOL DriveManager_GetDiscInfoEx(DM_DISCINFOEX_PARAM *pdip);
BOOL DriveManager_GetDiscInfo2(DM_DISCINFO2_PARAM *pdip);

BOOL DriveManager_QueryTitle(DM_TITLE_PARAM *pdtp);

// MCI async
BOOL DriveManager_GetMCIInfo(DM_MCI_PARAM *pmcip);

//IMAPI async
BOOL DriveManager_GetIMAPIInfo(DM_IMAPI_PARAM *pIMAPI);


#endif //NULLSOFT_MLDISC_DRIVEMANAGER_HEADER