问题:
  我在调试此DLL文件时,报告错误为:尚未调用CoInitialize.
    跟踪进入VCL类库,在ADODB单元的TADOCommand类的构造函数中的这句出错:     FCommandObject := CreateADOObject(CLASS_Command) as _Command;
  不知是什么原因,请大虾帮帮忙,指点指点...=======================DLL文件====================================
library Project1;uses
  SysUtils,
  Classes,
  IniFiles,
  ADODB;const
  IniFile = 'C:\SystemIni.ini';
  
function ReadADOConnectionStr: ShortString; stdcall;
var
  Ini: TIniFile;
begin
  Ini := TIniFile.Create(IniFile);
  try
    Result := Ini.ReadString('ADOConnection', 'OracleConnectionStr', '');
  finally
    Ini.Free;
  end;
end;function ReadName(ZH: ShortString): ShortString; stdcall;
var
  Q: TADOQuery;
begin
  Q := TADOQuery.Create(nil);
  try
    Q.ConnectionString := ReadADOConnectionStr;
    Q.SQL.Text := 'select XM from HuiYuan where ZH = ''' + ZH + #39;
    try
      Q.Open;
    except
      Result := '';
      Abort;
    end;
    Result := Q.Fields[0].AsString;
    Q.Close;
  finally
    Q.Free;
  end;
end;exports
  ReadName;
end.
==================测试程序======================================================
unit TestUnit;interfaceuses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;const
  DLLFileName = 'Project1.dll';
  
type
  TForm1 = class(TForm)
    Label1: TLabel;
    Label2: TLabel;
    Edit1: TEdit;
    Edit2: TEdit;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
  TReadName = function (ZH: ShortString): ShortString; stdcall;var
  Form1: TForm1;
  ReadName: TReadName;
  LibraryHandle: THandle;
implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
begin
  LibraryHandle := LoadLibrary(DLLFileName);
  try
    if LibraryHandle = 0 then
      raise Exception.Create('不能加载DLL文件!');
    @ReadName := GetProcAddress(LibraryHandle, 'ReadName');
    if not (@ReadName = nil) then
      Edit2.Text := ReadName(Edit1.Text);
  finally
    FreeLibrary(LibraryHandle);
  end;
end;end.