Posted: Sun Jul 13, 2008 4:26 am
Michael Korolev wrote:sfs_Get_VariantString() function is absent everywhere: in Droopy and in include file
http://www.purebasic.com
https://www.purebasic.fr/english/
Michael Korolev wrote:sfs_Get_VariantString() function is absent everywhere: in Droopy and in include file
Code: Select all
;based on code from SFSxOI: http://www.purebasic.fr/english/viewtopic.php?t=30535
Procedure.S sfs_Get_VariantString(*Variant.VARIANT)
Protected String.S = ""
If VariantChangeType_(*Variant, *Variant, 0, #VT_BSTR) = #S_OK
String = PeekS(*Variant\bstrVal, -1, #PB_Unicode)
VariantClear_(*Variant)
Else
Debug "VariantChangeType() failed!"
EndIf
ProcedureReturn String
EndProcedure
Procedure.s ax_Uni2Ansi(unicodestr.l)
;user: aXend
;forum: http://www.purebasic.fr/english/viewtopic.php?t=16569
lenA = WideCharToMultiByte_(#CP_ACP, 0, unicodestr, -1, 0, 0, 0, 0);
ansistr.s = Space(lenA)
If (lenA > 0)
WideCharToMultiByte_(#CP_ACP, 0, unicodestr, -1, @ansistr, lenA, 0, 0);
EndIf
ProcedureReturn ansistr
EndProcedure
Procedure.l ugs_get_IMAPImediaType(driveletter.s)
DisableDebugger
Enumeration ;_#IMAPI_MEDIA_PHYSICAL_TYPE
#IMAPI_MEDIA_TYPE_UNKNOWN = 0
#IMAPI_MEDIA_TYPE_CDROM = $1
#IMAPI_MEDIA_TYPE_CDR = $2
#IMAPI_MEDIA_TYPE_CDRW = $3
#IMAPI_MEDIA_TYPE_DVDROM = $4
#IMAPI_MEDIA_TYPE_DVDRAM = $5
#IMAPI_MEDIA_TYPE_DVDPLUSR = $6
#IMAPI_MEDIA_TYPE_DVDPLUSRW = $7
#IMAPI_MEDIA_TYPE_DVDPLUSR_DUALLAYER = $8
#IMAPI_MEDIA_TYPE_DVDDASHR = $9
#IMAPI_MEDIA_TYPE_DVDDASHRW = $a
#IMAPI_MEDIA_TYPE_DVDDASHR_DUALLAYER = $b
#IMAPI_MEDIA_TYPE_DISK = $c
#IMAPI_MEDIA_TYPE_DVDPLUSRW_DUALLAYER = $0D
#IMAPI_MEDIA_TYPE_HDDVDROM = $0E
#IMAPI_MEDIA_TYPE_HDDVDR = $0F
#IMAPI_MEDIA_TYPE_HDDVDRAM = $10
#IMAPI_MEDIA_TYPE_BDROM = $11
#IMAPI_MEDIA_TYPE_BDR = $12
#IMAPI_MEDIA_TYPE_BDRE = $13
#IMAPI_MEDIA_TYPE_MAX = $13
EndEnumeration
Interface IDiscMaster2 Extends IDispatch
get__NewEnum(a)
get_Item(index,value)
get_Count(a.l)
get_IsSupportedEnvironment(value.l)
EndInterface
Interface IDiscRecorder2 Extends IDispatch
EjectMedia()
CloseTray()
AcquireExclusiveAccess(a.l,b.s)
ReleaseExclusiveAccess()
DisableMcn()
EnableMcn()
InitializeDiscRecorder(a.l)
get_ActiveDiscRecorder(value)
get_VendorId(value)
get_ProductId(value)
get_ProductRevision(value)
get_VolumeName(value)
get_VolumePathNames(value)
get_DeviceCanLoadMedia(a.l)
get_LegacyDeviceNumber(a.l)
get_SupportedFeaturePages(a)
get_CurrentFeaturePages(a)
get_SupportedProfiles(a)
get_CurrentProfiles(a)
get_SupportedModePages(a)
get_ExclusiveAccessOwner(value)
EndInterface
Interface IDiscFormat2 Extends IDispatch
IsRecorderSupported(recorder.l, value.l)
IsCurrentMediaSupported(recorder.l, value.l)
get_MediaPhysicallyBlank(value.l)
get_MediaHeuristicallyBlank(value.l)
get_SupportedMediaTypes(value.l)
EndInterface
Interface IDiscFormat2Erase Extends IDiscFormat2
put_Recorder(value)
get_Recorder(value)
put_FullErase(value)
get_FullErase(value)
get_CurrentPhysicalMediaType(value)
put_ClientName(value.p-bstr)
get_ClientName(value)
EraseMedia()
EndInterface
Structure SAFEARRAYBOUND
cElements.L ; # of elements in the array dimension
lLbound.L ; Lower bounds of the array dimension
EndStructure
Structure SAFEARRAY
cDims.W
fFeatures.W
cbElements.L
cLocks.L
pvData.L
rgsabound.SAFEARRAYBOUND[60]
EndStructure
pp.variant
pp\vt = #VT_BSTR
Variant.VARIANT
*VariantArray.SAFEARRAY
thisletter.s = ""
CoInitialize_(0)
CoCreateInstance_(?CLSID_MsftDiscMaster2,0,1,?IID_IDiscMaster2,@DiscMaster.IDiscMaster2)
DiscMaster\get_Count(@count)
Debug driveletter
For imapidrives = 0 To count
Debug " "
DiscMaster\get_Item(imapidrives,@pp\bstrval)
CoCreateInstance_(?CLSID_MsftDiscRecorder2,0,1,?IID_IDiscRecorder2,@Recorder.IDiscRecorder2)
Recorder\InitializeDiscRecorder(pp\bstrval)
CoCreateInstance_(?CLSID_MsftDiscFormat2Erase,0,1,?IID_IDiscFormat2Erase,@Format.IDiscFormat2Erase)
Format\put_Recorder(Recorder)
Recorder\InitializeDiscRecorder(pp\bstrval)
Debug "drive: " +Str(imapidrives) +" is ID: " +ax_Uni2Ansi(pp\bstrval)
Recorder\get_ProductId(@pp\bstrval)
Debug "ProductID: "+ax_Uni2Ansi(pp\bstrval)
Recorder\get_VolumePathNames(@value.SAFEARRAY)
Variant\parray = PeekL(value)
*VariantArray = Variant\parray
For i = 1 To *VariantArray\rgsabound[0]\cElements
*Variant = *VariantArray\pvData + (i - 1) * 16
thisletter = sfs_Get_VariantString(*Variant)
Debug "Your Drive Path is: " +thisletter
med_type = Format\get_CurrentPhysicalMediaType(@mediaType)
Debug mediatype
Next i
If thisletter = UCase(driveletter)
Break
EndIf
Debug ""
Next imapidrives
DiscMaster\Release()
Recorder\Release()
Format\Release()
CoUninitialize_()
DataSection
CLSID_MsftDiscMaster2:
Data.l $2735412E
Data.w $7F64,$5B0F
Data.b $8F,$00,$5D,$77,$AF,$BE,$26,$1E
CLSID_MsftDiscRecorder2:
Data.l $2735412D
Data.w $7F64,$5B0F
Data.b $8F,$00,$5D,$77,$AF,$BE,$26,$1E
CLSID_MsftDiscFormat2Erase:
Data.l $2735412B
Data.w $7F64,$5B0F
Data.b $8F,$00,$5D,$77,$AF,$BE,$26,$1E
IID_IDiscMaster2:
Data.l $27354130
Data.w $7F64,$5B0F
Data.b $8F,$00,$5D,$77,$AF,$BE,$26,$1E
IID_IDiscRecorder2:
Data.l $27354133
Data.w $7F64,$5B0F
Data.b $8F,$00,$5D,$77,$AF,$BE,$26,$1E
IID_IDiscFormat2Erase:
Data.l $27354156
Data.w $8F64,$5B0F
Data.b $8F,$00,$5D,$77,$AF,$BE,$26,$1E
EndDataSection
EnableDebugger
ProcedureReturn mediatype
EndProcedure;ugs_get_IMAPImediaType(driveletter.s)
cdvdLW.s = "z:\"
Debug "LW to check: "+cdvdLW
thismediatype = ugs_get_IMAPImediaType(cdvdLW)
Debug thismediatype
Select thismediaType
Case #IMAPI_MEDIA_TYPE_UNKNOWN
Debug "Media Type is Unknown or no media loaded"
Case #IMAPI_MEDIA_TYPE_CDROM
Debug "Media Type is a CD-ROM (or burned CD-R)"
Case #IMAPI_MEDIA_TYPE_CDR
Debug "Media Type is CD-R"
Case #IMAPI_MEDIA_TYPE_CDRW
Debug "Media Type is CD-R/W"
Case #IMAPI_MEDIA_TYPE_DVDROM
Debug "Media Type is a DVD-ROM (or a burned DVD-R)"
Case #IMAPI_MEDIA_TYPE_DVDRAM
Debug "Media Type is DVD-RAM"
Case #IMAPI_MEDIA_TYPE_DVDPLUSR
Debug "Media Type is DVD+R"
Case #IMAPI_MEDIA_TYPE_DVDPLUSRW
Debug "Media Type is DVD+RW"
Case #IMAPI_MEDIA_TYPE_DVDPLUSR_DUALLAYER
Debug "Media Type is DVD+R DL"
Case #IMAPI_MEDIA_TYPE_DVDDASHR
Debug "Media Type is DVD-R"
Case #IMAPI_MEDIA_TYPE_DVDDASHRW
Debug "Media Type is DVD-RW"
Case #IMAPI_MEDIA_TYPE_DVDDASHR_DUALLAYER
Debug "Media Type is DVD-R DL"
Case #IMAPI_MEDIA_TYPE_DISK
Debug "Media Type is Disk"
Case #IMAPI_MEDIA_TYPE_DVDPLUSRW_DUALLAYER
Debug "Media Type is DVD+RW DL"
Case #IMAPI_MEDIA_TYPE_HDDVDROM
Debug "Media Type is HD DVD-ROM"
Case #IMAPI_MEDIA_TYPE_HDDVDR
Debug "Media Type is HD DVD-R"
Case #IMAPI_MEDIA_TYPE_HDDVDRAM
Debug "Media Type is HD DVD-RAM"
Case #IMAPI_MEDIA_TYPE_BDROM
Debug "Media Type is BD-ROM"
Case #IMAPI_MEDIA_TYPE_BDR
Debug "Media Type is BD-R"
Case #IMAPI_MEDIA_TYPE_BDRE
Debug "Media Type is BD-RE"
EndSelect
End
I don't think so.Michael Korolev wrote:Damn, IMAPI is too difficult for me
Well, at first I just posted the proc, which should have indicated, that it is only called for one drive.Michael Korolev wrote:Works! I didn't know that I need to define drive letter, I thought, this code enumerating them all
Just try to share knowledge here, when you feel to be able to help and don't hesitate coz of not so good English. There's always a way to explain and sometimes code tells more than thousand wordsMichael Korolev wrote:How I can thank you!?
AFAIK: Yes.Michael Korolev wrote:So, user need to have minimun WinXP SP2 with special update (IMAPI v2)?
Why? And Which 278 strings?Michael Korolev wrote:One thing is confusing that to know a drive letter I need to write 278 strings!
Code: Select all
; German forum: http://www.purebasic.fr/german/viewtopic.php?t=1895&highlight=
; Author: DataMiner (updated for PB 4.00 by Andre)
; Date: 05. February 2005
; OS: Windows
; Demo: No
Define.l Serial, type, i
Define.s Lfwrk, FileSystem, VolName
For i=65 To 90
Lfwrk=Chr(i)+":"
type =GetDriveType_(Lfwrk)
FileSystem = Space(256)
VolName= Space(256)
GetVolumeInformation_(@Lfwrk, @VolName, 255, @Serial, 0, 0, @FileSystem, 255)
Select type
Case 0
Debug Lfwrk+" The drive type cannot be determined."
Case 2
Debug Lfwrk+" = DRIVE_REMOVABLE, "+VolName+", "+FileSystem+", "+ Hex(Serial)
Case 3
Debug Lfwrk+" = DRIVE_FIXED, "+VolName+", "+FileSystem+", "+ Hex(Serial)
Case 4
Debug Lfwrk+" = DRIVE_REMOTE, "+VolName+", "+FileSystem+", "+ Hex(Serial)
Case 5
Debug Lfwrk+" = DRIVE_CDROM, "+VolName+", "+FileSystem+", "+ Hex(Serial)
Case 6
Debug Lfwrk+" = DRIVE_RAMDISK, "+VolName+", "+FileSystem+", "+ Hex(Serial)
EndSelect
Next
I think this is it : http://www.microsoft.com/downloads/deta ... laylang=enLe Soldat Inconnu wrote:... But i don't have this :
the mentioned "IMAPI"-patch
I think i skip this information, sorry![]()
What is this and where find this ?
Can't you just check to see whether the DiscMaster object is created successfully or not? If it fails, you can't do much anyway, so you could ask the user to ensure they have installed the patch.harff182 wrote:I hoped, there would be something like Get_IMAPIVersion_(), but now I will try something likeCode: Select all
If OpenLibrary(#PB_Any, "imapi2.dll") = 0 MessageRequester("Error","Problems with Imapi V2, consult the docs") EndIf