Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/393.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何将C语言结构定义转换成Java代码?_Java_C_Dll - Fatal编程技术网

如何将C语言结构定义转换成Java代码?

如何将C语言结构定义转换成Java代码?,java,c,dll,Java,C,Dll,我正在开发itlspproc.dll,它有本机方法,它有以下C语言的结构定义,但我必须用Java编写代码。在过去的三天里,我一直在搜索,但找不到解决方案 1.typedef struct{ unsigned __int64 FixedKey; // 8 byte number for fixed host key unsigned __int64 EncryptKey; // 8 Byte number for variable key

我正在开发
itlspproc.dll
,它有本机方法,它有以下C语言的结构定义,但我必须用Java编写代码。在过去的三天里,我一直在搜索,但找不到解决方案

1.typedef struct{
            unsigned __int64 FixedKey; // 8 byte number for fixed host key
            unsigned __int64 EncryptKey; // 8 Byte number for variable key
            }SSP_FULL_KEY;

            2.typedef struct{
            unsigned __int64 Generator;
            unsigned __int64 Modulus;
            unsigned __int64 HostInter;
            unsigned __int64 HostRandom;
            unsigned __int64 SlaveInterKey;
            unsigned __int64 SlaveRandom;
            unsigned __int64 KeyHost;
            unsigned __int64 KeySlave;
            }SSP_KEYS

            3.typedef struct{
            SSP_FULL_KEY Key; // the full key
            unsigned long BaudRate; // baud rate of the packet
            unsigned long Timeout; // how long in ms to wait for a reply from the slave
            unsigned char PortNumber; // the serial com port number of the host
            unsigned char SSPAddress; // the SSP address of the slave
            unsigned char RetryLevel; // how many retries to the slave for non-response
            unsigned char EncryptionStatus; // is this an encrypted command 0 – No, 1 - Yes
            unsigned char CommandDataLength; // Number of bytes in the command
            unsigned char CommandData[255]; // Array containing the command bytes
            unsigned char ResponseStatus; // Response Status (PORT_STATUS enum)
            unsigned char ResponseDataLength; // how many bytes in the response
            unsigned char ResponseData[255]; // an array of response data
            unsigned char IgnoreError; // flag to suppress error box (0 – display,1 suppress)
            }SSP_COMMAND
以下是我尝试过的Java代码,但我无法调用本机方法:

            public class SSP_FULL_KEY
                {
                    long FixedKey;
                    long EncryptKey;
                    public SSP_FULL_KEY(long fix, long encr)
                    {
                        FixedKey = fix;
                        EncryptKey = encr;
                    }
            }

        public class SSP_COMMAND
            {
                //string PortNumber; 
                SSP_FULL_KEY key;
                long BaudRate; // baud rate of the packet 
                long Timeout; // how long in ms to wait for a reply from the slave 
                String PortNumber; // the serial com port number of the host 
                String SSPAddress; // the SSP address of the slave 
                String RetryLevel; // how many retries to the slave for non-response 
                String EncryptionStatus; // is this an encrypted command 0 - No, 1 - Yes 
                String CommandDataLength; // Number of bytes in the command 
                String[] CommandData = new String[255]; // Array containing the command bytes 
                String ResponseStatus; // Response Status (PORT_STATUS enum) 
                String ResponseDataLength; // how many bytes in the response 
                String ResponseData[] = new String[255]; // an array of response data 
                String IgnoreError; // flag to suppress error box (0 - display,1- suppress) 

                public SSP_COMMAND(String comport)
                {
                    BaudRate = 9600;
                    Timeout = 500;
                    PortNumber =  comport;
                    RetryLevel = "5";
                    IgnoreError = "0";
                    EncryptionStatus = "0";
                    ResponseStatus = "0";
                    ResponseDataLength = "0";
                    SSPAddress = "0";
                    CommandDataLength = "0";
                    key = new SSP_FULL_KEY(012345670123, 012345670123);

                }
            } 



native method:OpenSSPComPort(SSPCOMMAND * cmd) 
这里我传递参数:


< C++ >使用了从C++到java或其他语言的在线转换。p>
    Pointer to SSP_COMMAND structure
    Returns:
    WORD 0 for fail, 1 for success