标签: imapi

有没有一种相对简单的方法来完成C#或PowerShell中的CD或DVD?

首先,对术语进行一些澄清.通过敲定,我并不是指关闭会话; 我的意思是写一个CD或DVD的引出方式,以便不再通过常用手段(Roxio,Nero,Windows资源管理器等)添加信息.

我对此做了大量的研究.有一些开源程序,如InfraRecorder,我们可以从中吸取一些灵感,但它们似乎都涉及使用IMAPI相当精细的C++代码,这似乎是一种非常低级的做事方式.我们都没有C++或IMAPI专业知识来支持这样的代码库.

互联网上最有前途的资源似乎就是这个,但似乎并没有包含最终化功能.这是"编写图像"的代码:

public void WriteImage(BurnVerificationLevel verification, bool finalize, bool eject)
{
    if (!_recorderLoaded)
        throw new InvalidOperationException("LoadMedia must be called first.");

    MsftDiscRecorder2 recorder = null;
    MsftDiscFormat2Data discFormatData = null;

    try
    {
        recorder = new MsftDiscRecorder2();
        recorder.InitializeDiscRecorder(_recorders.SelectedItem.InternalUniqueId);

        discFormatData = new MsftDiscFormat2Data
        {
            Recorder = recorder,
            ClientName = ClientName,
            ForceMediaToBeClosed = finalize
        };

        //
        // Set the verification level
        //
        var burnVerification = (IBurnVerification)discFormatData;
        burnVerification.BurnVerificationLevel = IMAPI_BURN_VERIFICATION_LEVEL.IMAPI_BURN_VERIFICATION_NONE;

        //
        // Check if media is blank, (for …
Run Code Online (Sandbox Code Playgroud)

c# powershell imapi

11
推荐指数
2
解决办法
1971
查看次数

使用PowerShell创建ISO映像:如何将IStream保存到文件?

我想在Windows上创建一个ISO映像,即.iso文件.这可以使用COM组件IMAPI2FS.MsftFileSystemImage,我在MSDN博客文章"在PowerShell中使用IMAPI 2编写光盘"中找到了如何使用PowerShell执行此操作的说明.

在第3步之后,这些指令说"在这一步你可以停止并将结果图像保存到本地硬盘,这将是一个纯粹的ISO图像."

我的问题:如何在PowerShell中获取$ resultStream,即检索ImageStream的COM对象,并将其内容保存到文件中?

com powershell imapi iso-image

8
推荐指数
1
解决办法
1万
查看次数

空白DVD /蓝光光盘(IMAPI)上的可用空间

由于我原来的问题有点过于模糊,让我澄清一下.

我的目标是:

  1. 通过IMAPI选择文件系统后估计空白光盘大小
  2. 如果我刻录它,估计我的文件将在此光盘上消耗的空间.

我想知道的是什么:

  1. 是否可以以编程方式为所选文件系统获取每个扇区的字节数
  2. 如果没有,IMAPI用于不同文件系统/媒体类型的每个扇区的字节是否有默认值,并在某处记录.

.net c# imapi

8
推荐指数
1
解决办法
2578
查看次数

如何获取CD/DVD驱动器上的文件更改通知?

我是C#的新手,必须在C#中开发Windows Form应用程序.此应用程序应跟踪以下内容.

  • 监控外部和内部的CD/DVD驱动器.
  • 监视在CD/DVD驱动器上创建,修改和删除的文件.

我可以RegisterNotification通过跟踪方法中的WM_DEVICECHANGE消息来获取CD/DVD驱动器插入的系统通知WndProc.

以上实现让我知道何时将新设备连接到PC.

我面临的问题是如何跟踪CD/DVD上发生的文件更改(写入/修改).一种选择是将CD/DVD中的文件轮询为后台作业.但是,这将是最后一个选择.

我发现IMAPI我们可以通过它写入CD/DVD但我只需要监视文件更改以进行审计.

请指点我如何在我的程序中接收CD/DVD通知上的文件更改?

我试过FileSystemWatcher但它似乎不适用于CD/DVD驱动器.

更新于2018年2月7日:

我能找到的另一种方法是通过WMI附加的查询WMI Events.我找到了一个Best way to detect dvd insertion in drive c#也可以得到答案的问题.我想知道在WMI中是否可以检测到DVD文件系统修改,以及是否有任何专家可以共享查询.我希望阿尔沙德能够在这方面提供帮助.

c# wmi wmi-query wpd imapi

8
推荐指数
1
解决办法
455
查看次数

CD刻录在XBAP中

I have an XBAP that needs to be able to burn cd's. When running from inside Visual Studio, everything works okay. However when running from a browser, the IMAPI dll reports that the environment is not supported as soon as it tries to access the drive.

I am assuming this is coming down to permissioning. I have a signed certificate which I have installed and the xbap is set to run as a full trust application (although I'm guessing that …

c# xbap imapi

6
推荐指数
1
解决办法
256
查看次数

MsftDiscFormat2Data事件处理程序

我已经使用Interop.cs成功地将IMAPI2集成到我的应用程序中.我可以毫无问题地刻录CD/DVD.但是,MsftDiscFormat2Data更新的事件处理程序不起作用,因此我无法使我的进度条移动.

这是我在codeproject网站上找到的代码:

private void backgroundBurnWorker_DoWork(object sender,DoWorkEventArgs e){MsftDiscRecorder2 discRecorder = null; MsftDiscFormat2Data discFormatData = null;

        try
        {
            //
            // Create and initialize the IDiscRecorder2 object
            //
            discRecorder = new MsftDiscRecorder2();
            var burnData = (BurnData)e.Argument;
            discRecorder.InitializeDiscRecorder(burnData.uniqueRecorderId);

            //
            // Create and initialize the IDiscFormat2Data
            //
            discFormatData = new MsftDiscFormat2Data
                {
                    Recorder = discRecorder,
                    ClientName = ClientName,
                    ForceMediaToBeClosed = _closeMedia
                };

            //
            // Set the verification level
            //
            var burnVerification = (IBurnVerification)discFormatData;
            burnVerification.BurnVerificationLevel = _verificationLevel;

            //
            // Check if media is blank, (for RW …
Run Code Online (Sandbox Code Playgroud)

c# imapi

6
推荐指数
1
解决办法
2152
查看次数

PowerShell:如何将COM对象转换为.NET互操作类型?

如我的问题中所述使用PowerShell创建ISO映像:如何将IStream保存到文件?,在PowerShell中我创建一个IStream对象如下:

$is = (New-Object -ComObject IMAPI2FS.MsftFileSystemImage).CreateResultImage().ImageStream
Run Code Online (Sandbox Code Playgroud)

此对象是(PowerShell)类型System.__ComObject.不知怎的,PowerShell知道它是IStream:

PS C:\> $is -is [System.Runtime.InteropServices.ComTypes.IConnectionPoint]
False
PS C:\> $is -is [System.Runtime.InteropServices.ComTypes.IStream]
True
Run Code Online (Sandbox Code Playgroud)

但是,此类型的强制转换失败:

PS C:\> [System.Runtime.InteropServices.ComTypes.IStream] $is
Cannot convert the "System.__ComObject" value of type "System.__ComObject" to type "System.Runtime.InteropServices.ComT
ypes.IStream".
At line:1 char:54
+ [System.Runtime.InteropServices.ComTypes.IStream] $is <<<<
    + CategoryInfo          : NotSpecified: (:) [], RuntimeException
    + FullyQualifiedErrorId : RuntimeException
Run Code Online (Sandbox Code Playgroud)

如何在不使用C#代码的情况下进行此转换?

更新:显然这种转换无法正常工作,正如x0n的回答所说的那样.

现在,我的目标是将此IStreamCOM对象传递给某些C#代码(使用相同的PowerShell脚本的一部分Add-Type),它将成为类型的.NET对象System.Runtime.InteropServices.ComTypes.IStream.那可能吗?如果没有,我有什么替代品?

com powershell com-interop powershell-2.0 imapi

6
推荐指数
2
解决办法
2890
查看次数

如何从c#刻录视频DVD?

我需要在C#应用程序中从我的网络摄像头刻录视频DVD吗?做正确的方法是什么?需要什么步骤?

我想我必须使用正确的文件夹结构和MPEG2视频创建图像,然后将其刻录到DVD?IMAPI2?

c# video dvd dvd-burning imapi

3
推荐指数
1
解决办法
3039
查看次数

.NET中的IMAPI2 MsftFileSystemImage在创建ISO时不释放文件

我成功地创建了iso映像,但是在调用此Create方法返回后,我尝试删除rootFolderPath中的文件时出现'文件正在使用'IO错误.我错过了Marshal.ReleaseComObject调用吗?

谢谢,

CW

/// <summary>
/// Create iso image from rootFolderPath and write to isoImageFilePath. Does not include the actual rootFolder itself
/// </summary>
public void Create()
{
    IFileSystemImage ifsi = new MsftFileSystemImage();
    try
    {
        ifsi.ChooseImageDefaultsForMediaType(IMAPI_MEDIA_PHYSICAL_TYPE.IMAPI_MEDIA_TYPE_DISK);
        ifsi.FileSystemsToCreate =
                FsiFileSystems.FsiFileSystemJoliet | FsiFileSystems.FsiFileSystemISO9660;
        ifsi.VolumeName = this.volumeName;
        ifsi.Root.AddTree(rootFolderPath, false);//use a valid folder
        //this will implement the Write method for the formatter
        IStream imagestream = ifsi.CreateResultImage().ImageStream;
        if (imagestream != null)
        {
            System.Runtime.InteropServices.ComTypes.STATSTG stat;
            imagestream.Stat(out stat, 0x01);
            IStream newStream;
            if (0 == SHCreateStreamOnFile(isoImageFilepath, 0x00001001, out …
Run Code Online (Sandbox Code Playgroud)

c# interop imapi

3
推荐指数
1
解决办法
2664
查看次数