我得到以下情况:
我想从我的Pascal程序中调用一个C函数.C函数应该用值填充传递的指针.
这是C函数:
DLLEXPORT int dpstate_callPluginFunction(const char* plugin, const char* function, bool synchronous, const char* p0, const char* p1, const char* p2, const char* p3, const char* p4, const char* p5, const char* p6, char** o0, char** o1, char** o2, char** o3, char** o4, char** o5, char** o6)
Run Code Online (Sandbox Code Playgroud)
"p"参数是输入参数,"o"参数是输出参数.我试图在我的Pascal程序中调用该函数,如下所示:
C Functioncall声明:
var dpstate_callPluginFunction: function(plugin, method: PAnsiChar; synchronous: boolean; p0, p1, p2, p3, p4, p5, p6: PAnsiChar; o0, o1, o2, o3, o4, o5, o7: PPAnsiChar): integer; cdecl;
Run Code Online (Sandbox Code Playgroud)
C功能调用加载:
@dpstate_callPluginFunction:= GetProcAddress(mConnectorLibrary, 'dpstate_callPluginFunction'); …Run Code Online (Sandbox Code Playgroud) 我想创建一个名为"CustomParam"的类的指针,所以我声明了
pCustomParam = ^CustomParam
Run Code Online (Sandbox Code Playgroud)
Class CustomParam得到了以下类变量,它们应该在构造函数中设置为0:
var keyArray: array of String;
var valueArray: array of String;
var paramArray: array of pCustomParam;
var isParamArray: array of Boolean;
var size: Integer;
Run Code Online (Sandbox Code Playgroud)
构造函数看起来像这样:
constructor CustomParam.create;
begin
inherited;
size:= 0;
SetLength(keyArray,0);
SetLength(valueArray,0);
SetLength(isParamArray,0);
SetLength(paramArray,0);
end;
Run Code Online (Sandbox Code Playgroud)
并被宣布为:
constructor create; overload;
Run Code Online (Sandbox Code Playgroud)
现在我尝试用"new"创建指向CustomParam的指针,如下所示:
var pointerToCustomParam: pCustomParam;
begin
new(pointerToCustomParam);
Run Code Online (Sandbox Code Playgroud)
但它不会跳转到CustomParam类的构造函数.如果我手动调用构造函数如下:
pointerToCustomParam^.create;
Run Code Online (Sandbox Code Playgroud)
应用程序将在SetLength命令上崩溃.
我注意到的是,变量"pointerToCustomParam"在"新"函数之后直接得到了垃圾内容.
我希望你能帮助我,信息足够:)
谢谢 :)
我是Visual Studio Code中Java的新手,正在尝试实现小型应用程序,该应用程序使用位于内部Git存储库中的SDK。
当尝试调试我的应用程序时,出现以下错误:
vscode.java.validateLaunchConfig没有委托命令处理程序
我的配置文件看起来非常简单:
{
"configurations": [
{
"type": "java",
"name": "CodeLens (Launch) - App",
"request": "launch",
"mainClass": "com.my.first.class",
"projectName": "dummyproject"
}
]
}
Run Code Online (Sandbox Code Playgroud)
我正在使用以下Visual Studio Code扩展:
我正在编写一个使用C-DLL的工具.C-DLL的功能期望a char*,其为UTF-8格式.我的问题:我可以通过PChar或必须使用UTF8Encode(string)吗?