首页 > 解决方案 > 使用 dll 文件在我的应用程序 delphi 中出错

问题描述

我在 C# 中有使用 Z339xLib.dll 文件的库代码,代码是:

#region Assembly Z339xLib.dll, v4.0.30319
// C:\Documents and Settings\Hytham\Desktop\Software Protocol n Image Capture SDK_New\Software Protocol n Image Capture SDK\Z339x_SDK_Sample\Z339x_SDK_Sample\bin\Debug\Z339xLib.dll
#endregion

using System;
using System.Drawing;

namespace Z339xLib
{
    public class Z339xLibSdk
    {
        public Z339xLibSdk();

        public bool GetImageAndSaveFile(string portname, string filename, int type);
        public Bitmap GetImageByBitmap(string portname);
        public string SearchDevice_VCOM();
    }
}

我需要将此代码转换为 delphi 编程,我在 delphi 中创建一个代码,如下所示:

unit Z339xLib_Sdk;

interface
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics,Controls,Dialogs,
  StdCtrls, ExtCtrls;

Const Z339xLibSdk = 'Z339xLib.dll';
function GetImageAndSaveFile(hport:WideString;ImageDir:WideString;Imagetype:integer): boolean; stdcall;external Z339xLibSdk;
function GetImageByBitmap(hport:WideString): BITMAP; stdcall;external Z339xLibSdk;
function SearchDevice_VCOM : string; stdcall;external Z339xLibSdk;

implementation

end.

调用函数时出现错误:

应用程序未能正确初始化(0xc000007b)

请任何帮助或我的 syantex 代码有任何问题。

这是对功能的解释:

Function    bool GetImageAndSaveFile(String Port_Name, String File_Name, int Format);
Parameters  String Port_Name = Virual Com Port Name(ex. COM1…).
Or you can just use “AUTO” as a serial port name, system will automatic search the device.
String File_Name    A string that contains the name of the file to which to save this Image.
int Format  Image Format
0: png
1:bmp
2:Jpeg
3:Tiff
Return values   True: Success
False: error occurred.

感谢您的帮助

标签: c#delphidelphi-7

解决方案


推荐阅读