我做的一个project的例子:<br>library Hawb_Status;<br><br>uses<br> Forms,<br> SysUtils,<br> Ole2,<br> ADODB,<br> U_Input_HStatus in 'U_Input_HStatus.pas' {F_Input_HStatus},<br> U_DM_HStatus in 'U_DM_HStatus.pas' {F_DM_HStatus: TDataModule},<br> U_List_HStatus in 'U_List_HStatus.pas' {F_List_HStatus},<br> U_SaveLoadF in 'U_SaveLoadF.pas' {F_SaveLoadF},<br> U_SaveLoadIni in 'U_SaveLoadIni.pas' {F_SaveLoadIni},<br> U_Search_HStatus in 'U_Search_HStatus.pas' {F_Search_HStatus},<br> U_ListDef_HStatus in 'U_ListDef_HStatus.pas' {F_ListDef_HStatus},<br> U_SHawb_Hint in 'U_SHawb_Hint.pas' {F_SHawb_Hint},<br> hawblistf in 'hawblistf.pas' {ListPreview},<br> u_hstatus_dest in 'u_hstatus_dest.pas' {F_HStatus_dest};<br><br>{$R *.RES}<br><br>function MainRunning(AUser: PChar; Privilege: Integer; WorkPath: PChar;<br> Conn: TADOConnection; TableName, KeyFld: PChar): Boolean; stdcall;<br><br>begin<br> ShortDayNames[1]:='Sun';<br> ShortDayNames[2]:='Mon';<br> ShortDayNames[3]:='Tue';<br> ShortDayNames[4]:='Wed';<br> ShortDayNames[5]:='Thu';<br> ShortDayNames[6]:='Fri';<br> ShortDayNames[7]:='Sat';<br> LongDayNames[1]:='Sun';<br> LongDayNames[2]:='Mon';<br> LongDayNames[3]:='Tue';<br> LongDayNames[4]:='Wed';<br> LongDayNames[5]:='Thu';<br> LongDayNames[6]:='Fri';<br> LongDayNames[7]:='Sat';<br> _LoginUsr := StrPas(AUser);<br> _TableName := TableName; <br> _UserPrivilege := Privilege;<br> if WorkPath = nil then<br> _WorkPath := ''<br> else<br> _WorkPath := StrPas(WorkPath);<br> CoInitialize(nil);<br> F_DM_HStatus := TF_DM_HStatus.Create(Application);<br> F_DM_HStatus.MainTable.KeyFldName := StrPas(KeyFld);<br> F_DM_HStatus.MainTable.Connection := Conn;<br> F_DM_HStatus.LookupQry.Connection := Conn;<br> F_DM_HStatus.ExecCommand.Connection := Conn;<br> F_DM_HStatus.adodataset1.connection := Conn;<br> F_DM_HStatus.adostoredproc1.connection := conn;<br> F_Input_HStatus := TF_Input_HStatus.Create(Application);<br> F_Search_HStatus := TF_Search_HStatus.Create(Application);<br> F_List_HStatus := TF_List_HStatus.Create(Application);<br> F_ListDef_HStatus := TF_ListDef_HStatus.Create(Application);<br> F_SaveLoadF := TF_SaveLoadF.Create(Application);<br> F_SaveLoadIni := TF_SaveLoadIni.Create(Application);<br> F_SHawb_Hint :=TF_SHawb_Hint.Create(Application);<br> lstpreview := tlstpreview.create(application);<br> f_hstatus_dest := tf_hstatus_dest.Create(application);<br> f_input_hstatus.showmodal;<br> FreeAndNil(F_Input_HStatus);<br><br> FreeAndNil(F_Search_HStatus);<br> FreeAndNil(F_List_HStatus);<br> FreeAndNil(F_ListDef_HStatus);<br> FreeAndNil(F_SaveLoadF);<br> FreeAndNil(F_SaveLoadIni);<br> FreeAndNil(F_SHawb_Hint);<br> FreeAndNil(F_DM_HStatus);<br> coUnInitialize;<br> Result := True;<br>end;<br><br>exports<br> MainRunning name 'MainRunning';<br><br>end.