软件的升级是怎么实现的? (50分)

  • 主题发起人 主题发起人 eluian
  • 开始时间 开始时间
E

eluian

Unregistered / Unconfirmed
GUEST, unregistred user!
最近本人做了一个小软件,送给人用了,但是我后来对程序有进行了一些改动,
想重新送给他用,但我在想是不是能做到像专业软件那样,只要升级一下就可以了,
而不用卸载——重新安装这样一个过程。有哪位高手能否介绍介绍专业软件是如何
实现升级的?
 
procedure TrepForm.doit;
var
i,j,k1,k2,kkkk:integer;
memolist:tstringlist;
s_dj,s_zj:string;
tot:real;
begin
tot:=0;
try
MsExcel:=CreateOleObject('Excel.Application');
MsExcelWorkBook:=MsExcel.WorkBooks.Add;
MsExcelWorkSheet:=MsExcel.Sheets['Sheet1'];
except
showerror('无法打开 EXCEL 97');
exit;
end;
memolist:=tstringlist.Create;
MsExcel.Visible:=True;
MsExcelWorkSheet.Range['A2:E2'].select;
MsExcel.Selection.merge;
MsExcel.Selection.HorizontalAlignment:=3;
MsExcel.Selection.VerticalAlignment:=2;
MsExcelWorkSheet.Range['A2:E2'].value:='采购合同';
kkkk:=4;
MsExcelWorkSheet.Range['C'+inttostr(kkkk)+':E'+inttostr(kkkk)].select;
MsExcel.Selection.merge;
MsExcel.Selection.HorizontalAlignment:=2;
MsExcel.Selection.VerticalAlignment:=2;
MsExcelWorkSheet.Range['C'+inttostr(kkkk)+':E'+inttostr(kkkk)].value:='合同号码:'+maintable.fieldbyname('ht_id').asstring;
memolist.assign(maintable.fieldbyname('bftt'));
if memolist.count=0 then
memolist.add(maintable.fieldbyname('wfgs').asstring);
MsExcelWorkSheet.Range['A'+inttostr(kkkk)+':B'+inttostr(kkkk)].select;
MsExcel.Selection.merge;
MsExcel.Selection.HorizontalAlignment:=2;
MsExcel.Selection.VerticalAlignment:=2;
MsExcelWorkSheet.Range['A'+inttostr(kkkk)+':B'+inttostr(kkkk)].value:='买方:'+memolist.strings[0];
for i:=1 to (memolist.count-1)do
begin
MsExcelWorkSheet.Range['A'+inttostr(kkkk+i)+':B'+inttostr(kkkk+i)].select;
MsExcel.Selection.merge;
MsExcel.Selection.HorizontalAlignment:=2;
MsExcel.Selection.VerticalAlignment:=2;
MsExcelWorkSheet.Range['A'+inttostr(kkkk+i)+':B'+inttostr(kkkk+i)].value:=kong(7)+memolist.strings;
end;
kkkk:=kkkk+memolist.count;
MsExcelWorkSheet.Range['C'+inttostr(kkkk)+':E'+inttostr(kkkk)].select;
MsExcel.Selection.merge;
MsExcel.Selection.HorizontalAlignment:=2;
MsExcel.Selection.VerticalAlignment:=2;
MsExcelWorkSheet.Range['C'+inttostr(kkkk)+':E'+inttostr(kkkk)].value:='合同日期:'+maintable.fieldbyname('dateis').asstring;
memolist.assign(maintable.fieldbyname('ttr'));
if memolist.count=0 then
memolist.add(maintable.fieldbyname('supplier').asstring);
MsExcelWorkSheet.Range['A'+inttostr(kkkk)+':B'+inttostr(kkkk)].select;
MsExcel.Selection.merge;
MsExcel.Selection.HorizontalAlignment:=2;
MsExcel.Selection.VerticalAlignment:=2;
MsExcelWorkSheet.Range['A'+inttostr(kkkk)+':B'+inttostr(kkkk)].value:='卖方:'+memolist.strings[0];
for i:=1 to (memolist.count-1)do
begin
MsExcelWorkSheet.Range['A'+inttostr(kkkk+i)+':B'+inttostr(kkkk+i)].select;
MsExcel.Selection.merge;
MsExcel.Selection.HorizontalAlignment:=2;
MsExcel.Selection.VerticalAlignment:=2;
MsExcelWorkSheet.Range['A'+inttostr(kkkk+i)+':B'+inttostr(kkkk+i)].value:=kong(8)+memolist.strings;
end;
kkkk:=kkkk+memolist.count;
MsExcelWorkSheet.Range['A'+inttostr(kkkk)+':B'+inttostr(kkkk)].select;
MsExcel.Selection.merge;
MsExcel.Selection.HorizontalAlignment:=2;
MsExcel.Selection.VerticalAlignment:=2;
MsExcelWorkSheet.Range['A'+inttostr(kkkk)+':B'+inttostr(kkkk)].value:='签约地点:'+maintable.fieldbyname('qddd').asstring;
MsExcelWorkSheet.Range['C'+inttostr(kkkk)+':E'+inttostr(kkkk)].select;
MsExcel.Selection.merge;
MsExcel.Selection.HorizontalAlignment:=2;
MsExcel.Selection.VerticalAlignment:=2;
MsExcelWorkSheet.Range['C'+inttostr(kkkk)+':E'+inttostr(kkkk)].value:='交货日期:'+maintable.fieldbyname('jhdate').asstring;
kkkk:=kkkk+2;
MsExcelWorkSheet.Range['A'+inttostr(kkkk)+':E'+inttostr(kkkk)].select;
MsExcel.Selection.merge;
MsExcel.Selection.HorizontalAlignment:=2;
MsExcel.Selection.VerticalAlignment:=2;
MsExcelWorkSheet.Range['A'+inttostr(kkkk)+':E'+inttostr(kkkk)].value:='一、品名、规格、数量、金额:';
kkkk:=kkkk+1;
MsExcelWorkSheet.Range['A'+inttostr(kkkk)].Value:='货号';
MsExcelWorkSheet.Range['A'+inttostr(kkkk)].select;
MsExcel.selection.columnwidth:=15;
MsExcel.Selection.HorizontalAlignment:=2;
MsExcelWorkSheet.Range['B'+inttostr(kkkk)].Value:='品质说明';
MsExcelWorkSheet.Range['B'+inttostr(kkkk)].select;
MsExcel.selection.columnwidth:=30;
MsExcel.Selection.HorizontalAlignment:=2;
MsExcelWorkSheet.Range['C'+inttostr(kkkk)].Value:='数量';
MsExcelWorkSheet.Range['C'+inttostr(kkkk)].select;
MsExcel.selection.columnwidth:=10;
MsExcel.Selection.HorizontalAlignment:=2;
MsExcelWorkSheet.Range['D'+inttostr(kkkk)].Value:='单价';
MsExcelWorkSheet.Range['D'+inttostr(kkkk)].select;
MsExcel.selection.columnwidth:=12;
MsExcel.Selection.HorizontalAlignment:=2;
MsExcelWorkSheet.Range['E'+inttostr(kkkk)].Value:='总价';
MsExcelWorkSheet.Range['E'+inttostr(kkkk)].select;
MsExcel.selection.columnwidth:=10;
MsExcel.Selection.HorizontalAlignment:=2;
MsExcelWorkSheet.Range['A'+inttostr(kkkk)+':'+'E'+inttostr(kkkk)].select;
msexcel.selection.Borders[7].LineStyle:=1;//left
msexcel.selection.Borders[8].LineStyle:=1;//top
msexcel.selection.Borders[9].LineStyle:=1;//bottom
msexcel.selection.Borders[10].LineStyle:=1;//right
msexcel.selection.Borders[11].LineStyle:=1;//内部垂直
if qtsql.active then
qtsql.close;
qtsql.sql.clear;
qtsql.sql.Add('select * from nxhtsheet99');
qtsql.sql.Add('where ht_id='+''''+maintable.fieldbyname('ht_id').asstring+'''');
qtsql.open;
qtsql.first;
j:=1;
while qtsql.eof=falsedo
begin
memolist.Assign(qtsql.fieldbyname('shm'));
if memolist.count=0 then
memolist.add('');
s_dj:=maintable.fieldbyname('hbdm').asstring+qtsql.fieldbyname('unite_price').asstring+'/'+qtsql.fieldbyname('dw1').asstring;
s_zj:=maintable.fieldbyname('hbdm').asstring+format('%.2f',[qtsql.fieldbyname('unite_price').asfloat*qtsql.fieldbyname('pcs').asfloat]);
tot:=tot+qtsql.fieldbyname('unite_price').asfloat*qtsql.fieldbyname('pcs').asfloat;
MsExcelWorkSheet.Range['A'+inttostr(kkkk+j)].Value:=qtsql.fieldbyname('product_id').asstring;
MsExcelWorkSheet.Range['A'+inttostr(kkkk+j)].select;
MsExcel.Selection.HorizontalAlignment:=2;
MsExcelWorkSheet.Range['B'+inttostr(kkkk+j)].Value:=memolist.strings[0];
MsExcelWorkSheet.Range['B'+inttostr(kkkk+j)].select;
MsExcel.Selection.HorizontalAlignment:=2;
MsExcelWorkSheet.Range['C'+inttostr(kkkk+j)].Value:=qtsql.fieldbyname('pcs').asstring+qtsql.fieldbyname('dw1').asstring;
MsExcelWorkSheet.Range['C'+inttostr(kkkk+j)].select;
MsExcel.Selection.HorizontalAlignment:=2;
MsExcelWorkSheet.Range['D'+inttostr(kkkk+j)].Value:=s_dj;
MsExcelWorkSheet.Range['D'+inttostr(kkkk+j)].select;
MsExcel.Selection.HorizontalAlignment:=2;
MsExcelWorkSheet.Range['E'+inttostr(kkkk+j)].Value:=s_zj;
MsExcelWorkSheet.Range['E'+inttostr(kkkk+j)].select;
MsExcel.Selection.HorizontalAlignment:=2;
k1:=j;
for i:=1 to (memolist.count-1)do
begin
j:=j+1;
MsExcelWorkSheet.Range['A'+inttostr(kkkk+j)].Value:='';
MsExcelWorkSheet.Range['A'+inttostr(kkkk+j)].select;
MsExcel.Selection.HorizontalAlignment:=2;
MsExcelWorkSheet.Range['B'+inttostr(kkkk+j)].Value:=memolist.strings;
MsExcelWorkSheet.Range['B'+inttostr(kkkk+j)].select;
MsExcel.Selection.HorizontalAlignment:=2;
MsExcelWorkSheet.Range['C'+inttostr(kkkk+j)].Value:='';
MsExcelWorkSheet.Range['C'+inttostr(kkkk+j)].select;
MsExcel.Selection.HorizontalAlignment:=2;
MsExcelWorkSheet.Range['D'+inttostr(kkkk+j)].Value:='';
MsExcelWorkSheet.Range['D'+inttostr(kkkk+j)].select;
MsExcel.Selection.HorizontalAlignment:=2;
MsExcelWorkSheet.Range['E'+inttostr(kkkk+j)].Value:='';
MsExcelWorkSheet.Range['E'+inttostr(kkkk+j)].select;
MsExcel.Selection.HorizontalAlignment:=2;
end;
k2:=j;
MsExcelWorkSheet.Range['A'+inttostr(kkkk+k1)+':A'+inttostr(kkkk+k2)].select;
MsExcel.Selection.merge;
MsExcel.Selection.HorizontalAlignment:=2;
MsExcel.Selection.VerticalAlignment:=1;
// MsExcelWorkSheet.Range['B'+inttostr(kkkk+k1)+':B'+inttostr(kkkk+k2)].select;
// MsExcel.Selection.merge;
MsExcelWorkSheet.Range['C'+inttostr(kkkk+k1)+':C'+inttostr(kkkk+k2)].select;
MsExcel.Selection.merge;
MsExcel.Selection.HorizontalAlignment:=2;
MsExcel.Selection.VerticalAlignment:=1;
MsExcelWorkSheet.Range['D'+inttostr(kkkk+k1)+':D'+inttostr(kkkk+k2)].select;
MsExcel.Selection.merge;
MsExcel.Selection.HorizontalAlignment:=2;
MsExcel.Selection.VerticalAlignment:=1;
MsExcelWorkSheet.Range['E'+inttostr(kkkk+k1)+':E'+inttostr(kkkk+k2)].select;
MsExcel.Selection.merge;
MsExcel.Selection.HorizontalAlignment:=2;
MsExcel.Selection.VerticalAlignment:=1;
MsExcelWorkSheet.Range['A'+inttostr(kkkk+k1)+':E'+inttostr(kkkk+k2)].select;
msexcel.selection.Borders[7].LineStyle:=1;//left
msexcel.selection.Borders[8].LineStyle:=1;//top
msexcel.selection.Borders[9].LineStyle:=1;//bottom
msexcel.selection.Borders[10].LineStyle:=1;//right
msexcel.selection.Borders[11].LineStyle:=1;//内部垂直
j:=j+1;
qtsql.next;
end;
kkkk:=kkkk+j;
MsExcelWorkSheet.Range['A'+inttostr(kkkk)+':D'+inttostr(kkkk)].select;
MsExcel.Selection.merge;
MsExcel.Selection.HorizontalAlignment:=4;
MsExcel.Selection.VerticalAlignment:=2;
MsExcelWorkSheet.Range['A'+inttostr(kkkk)+':D'+inttostr(kkkk)].value:='金额合计:';
MsExcelWorkSheet.Range['E'+inttostr(kkkk)+':E'+inttostr(kkkk)].select;
MsExcel.Selection.HorizontalAlignment:=2;
MsExcel.Selection.VerticalAlignment:=2;
MsExcelWorkSheet.Range['E'+inttostr(kkkk)+':E'+inttostr(kkkk)].value:=maintable.fieldbyname('hbdm').asstring+format('%.2f',[tot]);
kkkk:=kkkk+2;
MsExcelWorkSheet.Range['A'+inttostr(kkkk)+':E'+inttostr(kkkk)].select;
MsExcel.Selection.merge;
MsExcel.Selection.HorizontalAlignment:=2;
MsExcel.Selection.VerticalAlignment:=2;
MsExcelWorkSheet.Range['A'+inttostr(kkkk)+':E'+inttostr(kkkk)].value:='二、质量技术标准:'+maintable.fieldbyname('zlyq').asstring;
kkkk:=kkkk+1;
MsExcelWorkSheet.Range['A'+inttostr(kkkk)+':E'+inttostr(kkkk)].select;
MsExcel.Selection.merge;
MsExcel.Selection.HorizontalAlignment:=2;
MsExcel.Selection.VerticalAlignment:=2;
MsExcelWorkSheet.Range['A'+inttostr(kkkk)+':E'+inttostr(kkkk)].value:='三、交货地点:'+maintable.fieldbyname('fhyq').asstring;
kkkk:=kkkk+1;
MsExcelWorkSheet.Range['A'+inttostr(kkkk)+':E'+inttostr(kkkk)].select;
MsExcel.Selection.merge;
MsExcel.Selection.HorizontalAlignment:=2;
MsExcel.Selection.VerticalAlignment:=2;
MsExcelWorkSheet.Range['A'+inttostr(kkkk)+':E'+inttostr(kkkk)].value:='四、包装要求:'+maintable.fieldbyname('bzyq').asstring;
kkkk:=kkkk+1;
MsExcelWorkSheet.Range['A'+inttostr(kkkk)+':E'+inttostr(kkkk)].select;
MsExcel.Selection.merge;
MsExcel.Selection.HorizontalAlignment:=2;
MsExcel.Selection.VerticalAlignment:=2;
MsExcelWorkSheet.Range['A'+inttostr(kkkk)+':E'+inttostr(kkkk)].value:='五、质量检验:'+maintable.fieldbyname('jfcl').asstring;
kkkk:=kkkk+1;
MsExcelWorkSheet.Range['A'+inttostr(kkkk)+':E'+inttostr(kkkk)].select;
MsExcel.Selection.merge;
MsExcel.Selection.HorizontalAlignment:=2;
MsExcel.Selection.VerticalAlignment:=2;
MsExcelWorkSheet.Range['A'+inttostr(kkkk)+':E'+inttostr(kkkk)].value:='六、结算方式:'+maintable.fieldbyname('jsfs').asstring;
kkkk:=kkkk+1;
MsExcelWorkSheet.Range['A'+inttostr(kkkk)+':E'+inttostr(kkkk)].select;
MsExcel.Selection.merge;
MsExcel.Selection.HorizontalAlignment:=2;
MsExcel.Selection.VerticalAlignment:=2;
MsExcelWorkSheet.Range['A'+inttostr(kkkk)+':E'+inttostr(kkkk)].value:='七、运输要求:'+maintable.fieldbyname('ysfs').asstring;
kkkk:=kkkk+1;
MsExcelWorkSheet.Range['A'+inttostr(kkkk)+':E'+inttostr(kkkk)].select;
MsExcel.Selection.merge;
MsExcel.Selection.HorizontalAlignment:=2;
MsExcel.Selection.VerticalAlignment:=2;
MsExcelWorkSheet.Range['A'+inttostr(kkkk)+':E'+inttostr(kkkk)].value:='八、损耗计算:'+maintable.fieldbyname('shjs').asstring;
kkkk:=kkkk+1;
MsExcelWorkSheet.Range['A'+inttostr(kkkk)+':E'+inttostr(kkkk)].select;
MsExcel.Selection.merge;
MsExcel.Selection.HorizontalAlignment:=2;
MsExcel.Selection.VerticalAlignment:=2;
MsExcelWorkSheet.Range['A'+inttostr(kkkk)+':E'+inttostr(kkkk)].value:='九、配件供应:'+maintable.fieldbyname('pjgy').asstring;
memolist.assign(maintable.fieldbyname('memo'));
if memolist.count=0 then
memolist.add('');
MsExcelWorkSheet.Range['A'+inttostr(kkkk)+':E'+inttostr(kkkk)].select;
MsExcel.Selection.merge;
MsExcel.Selection.HorizontalAlignment:=2;
MsExcel.Selection.VerticalAlignment:=2;
MsExcelWorkSheet.Range['A'+inttostr(kkkk)+':E'+inttostr(kkkk)].value:='十、合同备注:'+memolist.strings[0];
for i:=1 to (memolist.count-1)do
begin
MsExcelWorkSheet.Range['A'+inttostr(kkkk+i)+':E'+inttostr(kkkk+i)].select;
MsExcel.Selection.merge;
MsExcel.Selection.HorizontalAlignment:=2;
MsExcel.Selection.VerticalAlignment:=2;
MsExcelWorkSheet.Range['A'+inttostr(kkkk+i)+':E'+inttostr(kkkk+i)].value:=kong(19)+memolist.strings;
end;
memolist.free;
end;
 
about Delphi 5.0中如何读取Excel 97文件
procedure TOfficeform.Button2Click(Sender: TObject);
var MSExcel:Variant;
i,j:Integer;
begin
SaveDialog1.Filter:='*.XLS¦*.XLS';
SaveDialog1.DefaultExt:='XLS';
if SaveDialog1.Execute then
begin
MSExcel:=CreateOLEObject('Excel.Application');
MSExcel.WorkBooks.Add;
MSExcel.Visible:=False;
Table1.Open;
j:=Table1.RecordCount;
Table1.First;
for i:=1 to jdo
begin
MSExcel.Cells[i,1].NumberFormat:='@';
MSExcel.Cells[i,1].Value:=Table1.FieldByName('CODE').AsString;
MSExcel.Cells[i,2].Value:=Table1.FieldByName('COLOR').AsString;
Table1.Next;
end;
MSExcel.ActiveWorkBook.SaveAs(SaveDialog1.FileName);
MSExcel.ActiveWorkBook.Saved:=True;
MSExcel.Quit;
end;
end;

利用Delphi 5中调用Excel 97
---- 在Delphi 5中简单地封装了一组Microsoft Office自动化对象(Automation servers)。它使得我们很容易地把Office中的应用程序(Word, Excel, PowerPoint, Outlook and Access等)当作一个com应用服务器进行控制。在Delphi 5中已经带了Word与PowerPoint的例子,因为Excel的调用与这两个应用服务器的调用略有不同,所以本人根据这两个例子写了个Excel 97的简单例子以供参考。
---- 步聚
1. 创建一个普通Application。
2. 在Form中分别放入ExcelApplication, ExcelWorkbook和ExcelWorksheet。
3. 连接Excel 97,具体方法如下:
打开Excel97。
Try
ExcelApplication1.Connect;
Except
end;
ExcelApplication1.Visible[0]:=True;
增加一个Workbook。
ExcelWorkbook1.ConnectTo(ExcelApplication1.
Workbooks.Add(EmptyParam,0));
添加一个Worksheet。
var
Temp_Worksheet: _WorkSheet;
begin
Try
Temp_Worksheet:=ExcelWorkbook1.
WorkSheets.Add(EmptyParam,
EmptyParam,EmptyParam,EmptyParam,0)
as _WorkSheet;//(注意)
ExcelWorkSheet1.ConnectTo(Temp_WorkSheet);
Except
ShowMessage('Failure');
end;
end;
关闭Excel.
Try
ExcelApplication1.Quit;
ExcelWorksheet1.Disconnect;
ExcelWorkbook1.Disconnect;
ExcelApplication1.Disconnect;
Except
end;
---- 4. 对Excel的一些操作:
选择当前Workbook的某一Worksheet.
procedure TForm1.ComboBox1DropDown
(Sender: TObject);
var
i: Integer;
begin
ComboBox1.Clear;
For i:=1 to ExcelWorkbook1.
Worksheets.Countdo
ComboBox1.Items.Add
((ExcelWorkbook1.Worksheets.Item
as _WorkSheet).Name);
end;

procedure TForm1.ComboBox1Change
(Sender: TObject);
begin
ExcelWorkSheet1.ConnectTo
(ExcelWorkbook1.Worksheets.Item
[ComboBox1.ItemIndex+1] as _WorkSheet);
ExcelWorkSheet1.Activate;
end;

选择某一Workbook:
procedure TForm1.ComboBox2DropDown
(Sender: TObject);
var
i: Integer;
begin
ComboBox2.Clear;
if ExcelApplication1.Workbooks.Count >0 then
For i:=1 to ExcelApplication1.Workbooks.Countdo
Combobox2.Items.Add(ExcelApplication1.
Workbooks.Item.Name);
end;

procedure TForm1.ComboBox2Change(Sender: TObject);
begin
ExcelWorkSheet1.Disconnect;
ExcelWorkBook1.ConnectTo(ExcelApplication1.Workbooks.
Item[Combobox2.ItemIndex+1]);
ExcelWorkBook1.Activate;
ExcelWorksheet1.ConnectTo(ExcelWorkBook1.
ActiveSheet as _WorkSheet);
ExcelWorkSheet1.Activate;
end;

对某一单元格进行赋值及取值。
procedure TForm1.Button5Click(Sender: TObject);
begin
ExcelWorksheet1.Cells.Item[SpinEdit2.Value,
SpinEdit1.Value]:=Edit1.Text;
end;

procedure TForm1.Button6Click(Sender: TObject);
begin
Edit1.Text:=ExcelWorksheet1.Cells.Item[
SpinEdit2.Value,SpinEdit1.Value];
end;

选择某一区域
ExcelWorkSheet1.Range['A1','C1'].Select;
打开一个Excel文件。
if OpenDialog1.Execute then
begin
Try
ExcelWorkBook1.ConnectTo
(ExcelApplication1.Workbooks.Open
(OpenDialog1.FileName,
EmptyParam,EmptyParam,EmptyParam,
EmptyParam,EmptyParam,
EmptyParam,EmptyParam,EmptyParam,
EmptyParam,EmptyParam,
EmptyParam,EmptyParam,0));
ExcelWorkSheet1.ConnectTo
(ExcelWorkBook1.Activesheet
as _Worksheet);
Except;
end;
end;
 
?????????????????
 
我是这么做的,判断是否旧的在运行,是,关闭,删除,把自己拷过去,如没有旧的,正常运行。
 
把一些可能升级的功能放到dll中,省级dll(更换)
 
1/通过互联网检查判断
2/下载需要的文件
3/删除自己 (另查找相关)
4/替换自己以及其他下载的文件
5/关闭自己,然后启动自己(办法也很多)
 
to:zheming
看错题目了吗?
同意爱元元的哥哥 的意见
如果主程序为MAIN。EXE
你可将子程序分为DLL 或 BPL
根据需要将DLL 或BPL 或EXE文件替换旧文件便可
 
多人接受答案了。
 
后退
顶部