Windows上的便携式设备路径 [英] Portable Device Path on Windows

查看:528
本文介绍了Windows上的便携式设备路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我实际上有一个Windows / Java问题。我有一个要通过Java访问的插入式设备。通常,您可以访问例如USB-Stick通过驱动器号...但是此平板电脑在Windows中显示为便携式设备...。这意味着该路径类似于 Computer\Archos 5S,并且没有驱动器号。

I've actually got an Windows/Java Question. I've got a plugged-in device which I want to access via Java. Normally you can access an e.g. USB-Stick via the Drive letter... but this tablet is displayed by Windows as a "Portable Device"... which means, that the Path is something like "Computer\Archos 5S" and there is no Drive letter.

我想通过Java访问此设备上的文件,但无法找出正确的路径。那里有一个类似的问题,但没有有效的答案。还是有另一种通过Java访问此设备的方法?

I want to access a file on this device via Java, but I am not able to figure out the correct path to it. There is a similar question out there, but without a productive answer. Or is there another way to access this device via Java?

实际上我还没有解决这个问题……我仍然无法通过Java访问此类设备。

Actually I've not solved this problem... I am still not able to access such a device via java.

此刻,我正在尝试访问Java中的Windows ShellFolder。
一个Shellfolder,例如: Shell ::: {35786D3C-B075-49b9-88DD-029876E11C01}

At the moment I am trying to access a windows ShellFolder in Java. A Shellfolder like: "Shell:::{35786D3C-B075-49b9-88DD-029876E11C01}"

Java可能吗?
最近我发现了sun.awt类 ShellFolder ...这是通缉的功能吗?

Is this possible with Java? Recently I uncovered the sun.awt class "ShellFolder"... is this the wanted feature?

感谢您的帮助
Rawi

thanks for your help Ripei

推荐答案

https://code.google.com/p/jmtp/

这是我的代码

package jmtp;

import be.derycke.pieter.com.COMException;
import be.derycke.pieter.com.Guid;
import java.io.*;
import java.math.BigInteger;
import jmtp.PortableDevice;
import jmtp.*;

public class Jmtp {

    public static void main(String[] args) {
        PortableDeviceManager manager = new PortableDeviceManager();
        PortableDevice device = manager.getDevices()[0];
        // Connect to my mp3-player
        device.open();

        System.out.println(device.getModel());

        System.out.println("---------------");

        // Iterate over deviceObjects
        for (PortableDeviceObject object : device.getRootObjects()) {
            // If the object is a storage object
            if (object instanceof PortableDeviceStorageObject) {
                PortableDeviceStorageObject storage = (PortableDeviceStorageObject) object;

                for (PortableDeviceObject o2 : storage.getChildObjects()) {
//                    
//                        BigInteger bigInteger1 = new BigInteger("123456789");
//                        File file = new File("c:/JavaAppletSigningGuide.pdf");
//                        try {
//                            storage.addAudioObject(file, "jj", "jj", bigInteger1);
//                        } catch (Exception e) {
//                            //System.out.println("Exception e = " + e);
//                        }
//                    

                    System.out.println(o2.getOriginalFileName());
                }
            }
        }

        manager.getDevices()[0].close();

    }
}

不要忘记添加jmtp.dll文件(jmtp下载附带)作为本机库。有关更多信息,请参见在Netbeans中包括本机库

Do not forget add jmtp.dll files (that comes up with jmtp download) as a native library. For more info, see my answer on Including Native Library in Netbeans.

这篇关于Windows上的便携式设备路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆