全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:4689
推到 Plurk!
推到 Facebook!

Delphi 操控 CodeSoft 初探 (使用DDE & ACTIVEX)

 
yachanga
資深會員


發表:24
回覆:335
積分:296
註冊:2003-09-27

發送簡訊給我
#1 引用回覆 回覆 發表時間:2005-06-29 18:20:07 IP:211.74.xxx.xxx 未訂閱
小弟最近試著用Delphi列印Codesoft 標籤, 發現網路上資訊蠻少的. 東湊西湊, 好不容易可以Run了, 分享一下使用心得. 希望各位大大指教    環境: 2000 程式: Delphi 6 搭配 CodeSoft 5.0    DDE Sample: -------------------------------
 var
   csini : tinifile;
   cspathloc : String;
   LOT : array[0..100] of char;
begin 
    csini := tinifile.create( 'win.ini' );
    cspathloc := csini.readstring('CS', 'Path', '' );
    csini.free;
    DDEWithCS.Connectmode := ddeautomatic;
    DDEWithCS.DDEService := 'Cs';
    DDEWithCS.DDETopic := 'Cs';
    DDEWithCS.ServiceApplication :=cspathloc   '\CS5.EXE' ;        if not DDEWithCS.SetLink('Cs', 'Cs') then
      raise Exception.Create ('Could not link to DDE server.');        if not DDEWithCS.ExecuteMacro('[OpenLab("XXX.LAB")]', FALSE ) then
       raise Exception.Create ('Unable to Execute Macro');         strpcopy(LOT ,'[Set(LOT,"333")]');
     DDEWithCS.ExecuteMacro(LOT,FALSE);
     DDEWithCS.ExecuteMacro('[printlabel(1)]',FALSE);
     DDEWithCS.ExecuteMacro('[FORMFEED()]',FALSE); 
ActiveX --------------------
var
  app,doc, vars, vari: Variant;
  i: Integer;
begin
 try
  app := CreateOleObject('Lppx.Application'); // Create Ole Object
  app.Visible := True;
  app.UserControl := True;      doc := app.ActiveDocument; // Link Doc      doc.Open('D:\XXX.Lab'); // Open Doc
  doc.PrintLabel(1);  // Print Label
  doc.FormFeed;  // Terminate Print job      vars := doc.Variables;   // Get Variables collections
  for i:= 1 to vars.count do begin
   vari:= vars.item(i);    // Get Variable 
   if  vari.Name='LOT' then
    begin
     vari.Value:='New Value';  // Update Variable Value
    end; 
  end;      app.Quit; // Exit Application     except
   raise Exception.Create('Error!!');
 end;
~悠遊法國號~ 發表人 - yachanga 於 2005/06/29 18:25:36
jiling16
一般會員


發表:0
回覆:1
積分:0
註冊:2007-05-10

發送簡訊給我
#2 引用回覆 回覆 發表時間:2007-05-10 12:45:19 IP:202.102.xxx.xxx 訂閱
是什么,前台要怎么写我用你的代码无法
------
LILYWANG
系統時間:2024-05-09 5:35:52
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!