想用delphi写一个打印程序,要用ADOQuery从表中查出要打印的内容,然后用第三方控件(报表)进行打印,然后编译成DLL文件。再调用的时候出错:Project Project2.Exe raised exception class EoleSysError with message '尚未调用 CoInitialize.'.
请各位大侠帮忙
请各位大侠帮忙
解决方案 »
- dbgrid一个字段显示两列
- 如何向word 和pdf 中写数据?
- DELPHI 7 能支持VISTA下的软件开发吗?
- !!!一个高三学生 对大学专业的选择问题!!!
- 如何调用Dll文件?
- 如何在DELPHI中调用C++写的数据库引擎?各位帮帮忙:)
- PrintDBGridEh的margin如何调整?
- Tquery 中的parambyname()函数相当于TADOQuery控件中的什么函数呢?
- 请教DBGrid问题:可否实现奇数行与偶数行以不同颜色显示?如何实现?给分
- 开发 类似qq视频聊天并具有给对方播放影音文件的功能,谁能给讲讲原理
- ListView怎样实现标题多行显示
- Windows NT Service能否有窗口??
在创建ADO对象之前,Coinitialize(nil)
完成使用之后 Couninitialize
library PSbSearch;{ Important note about DLL memory management: ShareMem must be the
first unit in your library's USES clause AND your project's (select
Project-View Source) USES clause if your DLL exports any procedures or
functions that pass strings as parameters or function results. This
applies to all strings passed to and from your DLL--even those that
are nested in records and classes. ShareMem is the interface unit to
the BORLNDMM.DLL shared memory manager, which must be deployed along
with your DLL. To avoid using BORLNDMM.DLL, pass string information
using PChar or ShortString parameters. }uses
SysUtils,
Classes,
SbFp in 'SbFp.pas' {frmSbSearch},
dtmdl in '..\dtmdl.pas' {dtmd: TDataModule};{$R *.res}begin
end.
------------------------------------------------------------------------------
unit SbFp;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, DBGrids, ExtCtrls, StdCtrls, Buttons, ComCtrls, DBCtrls,
Excel2000, OleServer, Menus,activex, Mask;type
TfrmSbSearch = class(TForm)
DBGrid1: TDBGrid;
grbxBaseInfo: TGroupBox;
dtpkGmrq: TDateTimePicker;
edDj: TEdit;
edCj: TEdit;
edSbid: TEdit;
cmbxDt: TComboBox;
cmbxdj: TComboBox;
btnSearch: TSpeedButton;
StaticText1: TStaticText;
GroupBox1: TGroupBox;
DBEdit1: TDBEdit;
DBEdit2: TDBEdit;
DBEdit3: TDBEdit;
DBEdit4: TDBEdit;
DBEdit8: TDBEdit;
DBEdit5: TDBEdit;
DBEdit6: TDBEdit;
Label2: TLabel;
DBEdit7: TDBEdit;
DBMemo1: TDBMemo;
DBImage1: TDBImage;
ckbxKs: TCheckBox;
cmbxks: TComboBox;
ExcelApplication1: TExcelApplication;
ExcelWorksheet1: TExcelWorksheet;
ExcelWorkbook1: TExcelWorkbook;
PopupMenu1: TPopupMenu;
N1: TMenuItem;
p: TPanel;
procedure ckbxKsClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure btnSearchClick(Sender: TObject);
procedure DBGrid1TitleClick(Column: TColumn);
procedure DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
procedure DBGrid1CellClick(Column: TColumn);
procedure edDjKeyPress(Sender: TObject; var Key: Char);
procedure N1Click(Sender: TObject);
private
lastColumn : integer;
icount : integer;
public
function ReturnSymbol(cmbx : TComboBox) : string;
end;var
frmSbSearch: TfrmSbSearch;implementationuses dtmdl, ADODB, DB;{$R *.dfm}procedure ShowSbSearch;stdcall
begin
CoInitialize(nil);//注意这里
dtmd := Tdtmd.Create(nil);
frmSbSearch := TfrmSbSearch.Create(nil);
try
frmSbSearch.ShowModal;
finally
frmSbSearch.Free;
dtmd.Free;
end;
CoUninitialize;
end;exports ShowSbSearch;//导出函数//下面是完成操作的程序代码-----------------------------------------------------------------------------------
var
MyPrint: TMyPrint;
begin
//CoInitialize(nil);//注意这里 {这里出错}
MyPrint := TMyPrint.Create(Application);
try
MyPrint.ShowModal;
finally
MyPrint.Free;
end;
//CoUninitialize;
end;
是怎么回事?
少了一个ActiveX