0

デスクトップ アプリケーションからデバイス ID を取得する必要があります。ここで、デバイスは Windows CE 5.0 ベースのハンドヘルド ターミナルであり、PC に接続されています。

デバイス内のアプリケーションからこの情報を取得するのは簡単です。たとえば、GetDeviceUniqueID または KernelIoControl WinApi メソッドのいずれかを使用できます

    [DllImport("coredll.dll")]
    private extern static int GetDeviceUniqueID([In, Out] byte[] appdata,
                           int cbApplictionData,
                            int dwDeviceIDVersion,
                            [In, Out] byte[] deviceIDOuput,
                            out uint pcbDeviceIDOutput);

    public byte[] GetDeviceID(string AppString)
    {
        // Call the GetDeviceUniqueID
        byte[] AppData = Encoding.Unicode.GetBytes(AppString);
        int appDataSize = AppData.Length;
        byte[] DeviceOutput = new byte[20];
        uint SizeOut = 20;
        GetDeviceUniqueID(AppData, appDataSize, 1, DeviceOutput, out SizeOut);
        return DeviceOutput;
    }

しかし、これをデスクトップ アプリケーションから取得する必要があります。

Windows Mobile 5.X SDK には、デスクトップ アプリからこの ID を取得するためのサンプルがあります。私は Windows CE を使用しているため、サンプルは ID を与えません (Windows モバイル用です)。

getDeviceIdSampleOutput

RAPI.Invoke() メソッド (または Opennetcf RAPI) を使用して、デスクトップ アプリから上記のメソッドを使用できると思います。しかし、 GetDeviceUniqueID などのマルチパラメータ WinApi メソッドで RAPI.Invoke を使用する方法がわかりません。

サンプル コードがあり、WinApi メソッドの C# シグネチャもコメントとして含まれています。

    //[DllImport("coredll.dll")]
    //private extern static int GetDeviceUniqueID([In, Out] byte[] appdata,
    //                       int cbApplictionData,
    //                        int dwDeviceIDVersion,
    //                        [In, Out] byte[] deviceIDOuput,
    //                        out uint pcbDeviceIDOutput);

    private void buttonGetDeviceID_Click(object sender, RoutedEventArgs e)
    {
        // RAPI
        RAPI rapi = new RAPI();
        rapi.Connect(true);
        // How do I pass several parameters inside a byte[] ?
        rapi.Invoke(@"\Windows\coredll.dll", "GetDeviceUniqueID", inputData, out outputData);
        //Process outputData
    }

ここにも同様の質問がありますが、解決策はありません。

4

1 に答える 1

1

ここで答えを見つけました。手短に; 直接的な方法はありません。WINAPI への呼び出しが行われる C で Win32 dll を作成し、それを \Windows フォルダーに展開する必要があります。その後、私はそれを使用することができますRAPI.Invoke()

また、これは実装を含む記事へのリンクです。

于 2015-08-06T06:28:26.257 に答える