我在delphi中编写usb口读写程序时,遇到了一些困难。原来用c++编写时,运用到了winioctl.h这个头文件,现在delphi中不知应当如何进行,望请高手指点。

解决方案 »

  1.   

    在delphi中也是调用这些api,  createfile之类的,你可以将c++的翻译成delphi的
      

  2.   

    不知道你用了什么函数先rundll32把地址读出来再test
      

  3.   

    //
    // Copyright (c) Microsoft Corporation.  All rights reserved.
    //
    //
    // Use of this source code is subject to the terms of the Microsoft end-user
    // license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
    // If you did not accept the terms of the EULA, you are not authorized to use
    // this source code. For a copy of the EULA, please see the LICENSE.RTF on your
    // install media.
    ///* 
     * Module Name: winioctl.h
     * Abstract: this module defines device IO control codes.
    */#ifndef _WINIOCTL_
    #define _WINIOCTL_//
    // Macro definition for defining IOCTL and FSCTL function control codes.  Note
    // that function codes 0-2047 are reserved for Microsoft Corporation, and
    // 2048-4095 are reserved for customers.
    //#define CTL_CODE( DeviceType, Function, Method, Access ) (                 \
        ((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method) \
    )//
    // Define the method codes for how buffers are passed for I/O and FS controls
    //#define METHOD_BUFFERED                 0
    #define METHOD_IN_DIRECT                1
    #define METHOD_OUT_DIRECT               2
    #define METHOD_NEITHER                  3//
    // Define the access check value for any access
    //
    //
    // The FILE_READ_ACCESS and FILE_WRITE_ACCESS constants are also defined in
    // ntioapi.h as FILE_READ_DATA and FILE_WRITE_DATA. The values for these
    // constants *MUST* always be in sync.
    //#define FILE_ANY_ACCESS                 0
    #define FILE_READ_ACCESS          ( 0x0001 )    // file & pipe
    #define FILE_WRITE_ACCESS         ( 0x0002 )    // file & pipe
    //
    // Define the various device type values.  Note that values used by Microsoft
    // Corporation are in the range 0-32767, and 32768-65535 are reserved for use
    // by customers.
    //#define DEVICE_TYPE ULONG#define FILE_DEVICE_BEEP                0x00000001
    #define FILE_DEVICE_CD_ROM              0x00000002
    #define FILE_DEVICE_CD_ROM_FILE_SYSTEM  0x00000003
    #define FILE_DEVICE_CONTROLLER          0x00000004
    #define FILE_DEVICE_DATALINK            0x00000005
    #define FILE_DEVICE_DFS                 0x00000006
    #define FILE_DEVICE_DISK                0x00000007
    #define FILE_DEVICE_DISK_FILE_SYSTEM    0x00000008
    #define FILE_DEVICE_FILE_SYSTEM         0x00000009
    #define FILE_DEVICE_INPORT_PORT         0x0000000a
    #define FILE_DEVICE_KEYBOARD            0x0000000b
    #define FILE_DEVICE_MAILSLOT            0x0000000c
    #define FILE_DEVICE_MIDI_IN             0x0000000d
    #define FILE_DEVICE_MIDI_OUT            0x0000000e
    #define FILE_DEVICE_MOUSE               0x0000000f
    #define FILE_DEVICE_MULTI_UNC_PROVIDER  0x00000010
    #define FILE_DEVICE_NAMED_PIPE          0x00000011
    #define FILE_DEVICE_NETWORK             0x00000012
    #define FILE_DEVICE_NETWORK_BROWSER     0x00000013
    #define FILE_DEVICE_NETWORK_FILE_SYSTEM 0x00000014
    #define FILE_DEVICE_NULL                0x00000015
    #define FILE_DEVICE_PARALLEL_PORT       0x00000016
    #define FILE_DEVICE_PHYSICAL_NETCARD    0x00000017
    #define FILE_DEVICE_PRINTER             0x00000018
    #define FILE_DEVICE_SCANNER             0x00000019
    #define FILE_DEVICE_SERIAL_MOUSE_PORT   0x0000001a
    #define FILE_DEVICE_SERIAL_PORT         0x0000001b
    #define FILE_DEVICE_SCREEN              0x0000001c
    #define FILE_DEVICE_SOUND               0x0000001d
    #define FILE_DEVICE_STREAMS             0x0000001e
    #define FILE_DEVICE_TAPE                0x0000001f
    #define FILE_DEVICE_TAPE_FILE_SYSTEM    0x00000020
    #define FILE_DEVICE_TRANSPORT           0x00000021
    #define FILE_DEVICE_UNKNOWN             0x00000022
    #define FILE_DEVICE_VIDEO               0x00000023
    #define FILE_DEVICE_VIRTUAL_DISK        0x00000024
    #define FILE_DEVICE_WAVE_IN             0x00000025
    #define FILE_DEVICE_WAVE_OUT            0x00000026
    #define FILE_DEVICE_8042_PORT           0x00000027
    #define FILE_DEVICE_NETWORK_REDIRECTOR  0x00000028
    #define FILE_DEVICE_BATTERY             0x00000029
    #define FILE_DEVICE_BUS_EXTENDER        0x0000002a
    #define FILE_DEVICE_MODEM               0x0000002b
    #define FILE_DEVICE_VDM                 0x0000002c
    #define FILE_DEVICE_MASS_STORAGE        0x0000002d
    #define FILE_DEVICE_SMB                 0x0000002e
    #define FILE_DEVICE_KS                  0x0000002f
    #define FILE_DEVICE_CHANGER             0x00000030
    #define FILE_DEVICE_SMARTCARD           0x00000031
    #define FILE_DEVICE_ACPI                0x00000032
    #define FILE_DEVICE_DVD                 0x00000033
    #define FILE_DEVICE_FULLSCREEN_VIDEO    0x00000034
    #define FILE_DEVICE_DFS_FILE_SYSTEM     0x00000035
    #define FILE_DEVICE_DFS_VOLUME          0x00000036//
    // Windows CE Specific Defines
    //
    #define FILE_DEVICE_HAL 0x00000101
    #define FILE_DEVICE_CONSOLE             0x00000102
    #define FILE_DEVICE_PSL 0x00000103
    #define FILE_DEVICE_SERVICE 0x00000104#endif // _WINIOCTL_------------------------------------------------------------------
    把上面有用到的东东转换成D的定义即可。
    比如:
      #define FILE_DEVICE_DFS_VOLUME  0x00000036---〉const FILE_DEVICE_DFS_VOLUME=$00000036;
      ....
      

  4.   

    同意lynmison的, 看看头文件大不大.遇常量转常量,遇到函数转函数,不过函数要从提供的链接库里引用出来就可以了.