对于我的项目,我需要测试路由器字符串是否使用 SAP Netweaver 7.0 成功连接到 SAP 服务器。我在 Visual Studio 2017 中创建了一个控制台应用程序。我已经给出了连接参数。但是应用程序以错误结束:无法读取内存
#include <stdlib.h>
#include <stdio.h>
#include "stdafx.h"
#include "include/sapnwrfc.h"
void errorHandling(RFC_RC rc, RFC_ERROR_INFO*errorInfo, RFC_CONNECTION_HANDLE connection) {
printfU(cU("%s: %s\n"), errorInfo->key, errorInfo->message);
/* It's better to close the TCP/IP connection cleanly, than tojust let the backend get a "Connection reset by peer" error...*/
if (connection != NULL) RfcCloseConnection(connection, errorInfo);
exit(1);
}
int mainU(int argc, SAP_UC** argv)
{
RFC_RC rc = RFC_OK;
RFC_CONNECTION_PARAMETER loginParams[6];
RFC_ERROR_INFO errorInfo;
RFC_CONNECTION_HANDLE connection;
// -----------------------------------------------
// OPEN CONNECTION
// -----------------------------------------------
// Create logon parameter list
loginParams[0].name = cU("gwhost");
loginParams[0].value = cU("80.**.***.**");
loginParams[1].name = cU("sysnr");
loginParams[1].value = cU("00");
loginParams[2].name = cU("client");
loginParams[2].value = cU("800");
loginParams[3].name = cU("user");
loginParams[3].value = cU("jsar12");
loginParams[4].name = cU("lang");
loginParams[4].value = cU("EN");
loginParams[5].name = cU("****");
loginParams[5].value = cU("Abc");
// Open connection
connection = RfcOpenConnection(loginParams, 6, &errorInfo);
if (connection == NULL) errorHandling(rc, &errorInfo, NULL);
return 0;
}
预期结果:连接到 SAP 路由器