#define CharSampleDevice_CLASS_GUID \
{ 0x2a57bdef, 0xbf9f, 0x4e7a, { 0x91, 0xcc, 0xaa, 0xfc, 0x56, 0x44, 0xe, 0xaf } }怎么用delphi 写 急  上面的guid 是自动生成的 需在delphi 中用到

解决方案 »

  1.   

    const
      CharSampleDevice_CLASS_GUID: TGUID = '{2A57BDEF-BF9F-4E7A-91CC-AAFC56440EAF}';//orconst
      CharSampleDevice_CLASS_GUID: TGUID = (D1: $2a57bdef; D2: $bf9f; D3: $4e7a;
        D4: ($91, $cc, $aa, $fc, $56, $44, $0e, $af));
      

  2.   

    to zswang
      如果我想在createfile()调用此GUID 函数的第一个参数应该怎么写
    我直接写CharSampleDevice_CLASS_GUID 总是失败 用getlasterror()得到的结果是0
     分数一并送出。。
      

  3.   

    如果用C怎么调的?
    如果用Delphi,你的调试代码是什么?
      

  4.   

    这是在driverstudio WDM 驱动程序中自动产生的 这是一部分 #define  CharSampleDevice_CLASS_GUID  \  
    {  0x2a57bdef,  0xbf9f,  0x4e7a,  {  0x91,  0xcc,  0xaa,  0xfc,  0x56,  0x44,  0xe,  0xaf  }  } GUID CharSampleDevice_Guid = CharSampleDevice_CLASS_GUID;
    #define NOCRYPT // prevent attempt to include missing files
    #define _INC_EXCPT // prevent excpt.h from being included
    GUID ClassGuid = CharSampleDevice_CLASS_GUID;
    HANDLE OpenByInterface(
    GUID* pClassGuid, // points to the GUID that identifies the interface class
    DWORD instance, // specifies which instance of the enumerated devices to open
    PDWORD pError // address of variable to receive error status
    )
    {
    HANDLE hDev;
    CDeviceInterfaceClass DevClass(pClassGuid, pError); if (*pError != ERROR_SUCCESS)
    return INVALID_HANDLE_VALUE; CDeviceInterface DevInterface(&DevClass, instance, pError); if (*pError != ERROR_SUCCESS)
    return INVALID_HANDLE_VALUE; hDev = CreateFile(
    DevInterface.DevicePath(),
    GENERIC_READ | GENERIC_WRITE,
    FILE_SHARE_READ | FILE_SHARE_WRITE,
    NULL,
    OPEN_EXISTING,
    FILE_ATTRIBUTE_NORMAL,
    NULL
    ); if (hDev == INVALID_HANDLE_VALUE)
    *pError = GetLastError(); return hDev;
    }
    hDevice = OpenByInterface( &ClassGuid, 0, &Error);
    if (hDevice == INVALID_HANDLE_VALUE)
    {
    printf("ERROR opening device: (%0x) returned from CreateFile\n", GetLastError());
    exit(1);
    }
    else
    {
    printf("Device found, handle open.\n");
    }
    上面是C的程序 是通过 openbyinterface()打开的 我再DELPHI 中不定义openbyinterface()函数 直接用createfile()该怎么写
      

  5.   

    这是在driverstudio WDM 驱动程序中自动产生的 这是一部分 #define  CharSampleDevice_CLASS_GUID  \  
    {  0x2a57bdef,  0xbf9f,  0x4e7a,  {  0x91,  0xcc,  0xaa,  0xfc,  0x56,  0x44,  0xe,  0xaf  }  } GUID CharSampleDevice_Guid = CharSampleDevice_CLASS_GUID;
    #define NOCRYPT // prevent attempt to include missing files
    #define _INC_EXCPT // prevent excpt.h from being included
    GUID ClassGuid = CharSampleDevice_CLASS_GUID;
    HANDLE OpenByInterface(
    GUID* pClassGuid, // points to the GUID that identifies the interface class
    DWORD instance, // specifies which instance of the enumerated devices to open
    PDWORD pError // address of variable to receive error status
    )
    {
    HANDLE hDev;
    CDeviceInterfaceClass DevClass(pClassGuid, pError); if (*pError != ERROR_SUCCESS)
    return INVALID_HANDLE_VALUE; CDeviceInterface DevInterface(&DevClass, instance, pError); if (*pError != ERROR_SUCCESS)
    return INVALID_HANDLE_VALUE; hDev = CreateFile(
    DevInterface.DevicePath(),
    GENERIC_READ | GENERIC_WRITE,
    FILE_SHARE_READ | FILE_SHARE_WRITE,
    NULL,
    OPEN_EXISTING,
    FILE_ATTRIBUTE_NORMAL,
    NULL
    ); if (hDev == INVALID_HANDLE_VALUE)
    *pError = GetLastError(); return hDev;
    }
    hDevice = OpenByInterface( &ClassGuid, 0, &Error);
    if (hDevice == INVALID_HANDLE_VALUE)
    {
    printf("ERROR opening device: (%0x) returned from CreateFile\n", GetLastError());
    exit(1);
    }
    else
    {
    printf("Device found, handle open.\n");
    }
    上面是C的程序 是通过 openbyinterface()打开的 我再DELPHI 中不定义openbyinterface()函数 直接用createfile()该怎么写