Tag: freepascal

pascal字符串如何在内存中表示?

pascal字符串如何在内存中排列? 我读到: http : //www.freepascal.org/docs-html/ref/refsu12.html它说字符串存储在堆上并且引用计数。 为了确定存储长度和引用的位置,我创建了一个字符串并对其进行了大量测试: type PInt = ^Integer; var str: String; begin str := ‘hello’; writeln(PInt(@str[1]) – (sizeof(integer) * 1)); //length writeln(PInt(@str[1]) – (sizeof(integer) * 2)); //reference count end. 第一个打印长度,第二个打印参考计数。 它做得非常好并且有效。 现在我试图在C中模仿同样的事情: Export char* NewCString() { const char* hello_ptr = “hello”; int length = strlen(hello_ptr); //allocate space on the heap for: sizeof(refcount) + […]

用Delphi消费C dll

我有一个带有此签名的Dll函数: UInt32 Authenticate(uint8 *Key); 我在Delphi上这样做: function Authenticate(Key:string) : UInt32; external ‘mylib.dll’ name ‘Authenticate’; 但总是,函数返回10(错误代码)和应用程序刹车: 有办法做到这一点吗? 更新: 谢谢你们! 你是最好的!