[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.6

How to interpret HRESULT for  Automation Server method call?

Asked by IT79637 in VB Script, Delphi Programming

Tags: Borland CodeGear, Delphi 7, Delphi 7

I have a Automation Server which I have added methods to.   It is a visible, out-of-process, apartment threaded.  When I defined the interfaces using the Type Library Editor, I thought I had included HRESULT as an automatic return value.  Maybe it is and I just don't know how to use it (LOL)?

A. Below is a screen shot of a method from the Type Library editor.

B.  In the code section are two programs in order:
1.  ImageDisplay_TLB.pas - automatically created by Type Library editor.
2.  ImageDisplayInterface.pas - where I write the interfaces and handle in/out variables passed from the calling program.

Questions:
1. Have I defined the interface so I can query HRESULT in the calling program?  If I have not, how do I setup HRESULT to use it?

2.  I call the server from vbscript (vbs) as follows:     iResult = mySrvObj.WorkInvoice(vCompany, vInvType, vDocID, vStaus)
mySrvObj is already instantiated.

After I make the method call, how do I interpert HRESULT in vbs?

Thanks much.

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
IMAGEDISPLAY_TBL.pas
unit ImageDisplay_TLB;
 
// PASTLWTR : 1.2
// File generated on 8/25/2008 12:34:32 PM from Type Library described below.
 
// ************************************************************************  //
// Type Lib: C:\Program Files\Borland\Delphi7\Projects\Display4Automation2\Display4Automation3\ImageDisplay.tlb (1)
// LIBID: {0EB7654F-85A7-4DB1-A9D6-4BC950E298B7}
// LCID: 0
// Helpfile: 
// HelpString: ImageDisplay Library
// DepndLst: 
//   (1) v2.0 stdole, (C:\WINDOWS\system32\stdole2.tlb)
// ************************************************************************ //
{$TYPEDADDRESS OFF} // Unit must be compiled without type-checked pointers. 
{$WARN SYMBOL_PLATFORM OFF}
{$WRITEABLECONST ON}
{$VARPROPSETTER ON}
interface
 
uses Windows, ActiveX, Classes, Graphics, StdVCL, Variants;
  
 
// *********************************************************************//
// GUIDS declared in the TypeLibrary. Following prefixes are used:        
//   Type Libraries     : LIBID_xxxx                                      
//   CoClasses          : CLASS_xxxx                                      
//   DISPInterfaces     : DIID_xxxx                                       
//   Non-DISP interfaces: IID_xxxx                                        
// *********************************************************************//
const
  // TypeLibrary Major and minor versions
  ImageDisplayMajorVersion = 1;
  ImageDisplayMinorVersion = 0;
 
  LIBID_ImageDisplay: TGUID = '{0EB7654F-85A7-4DB1-A9D6-4BC950E298B7}';
 
  IID_IImageDisplayInterface: TGUID = '{E7A22657-E720-4D79-A31F-C232390DB090}';
  DIID_IImageDisplayInterfaceEvents: TGUID = '{A9BD6966-B3C9-42D1-BEFD-549F87868AAA}';
  CLASS_ImageDisplayInterface: TGUID = '{A3087BD2-823D-4361-9970-E5AC0ED4A75F}';
type
 
// *********************************************************************//
// Forward declaration of types defined in TypeLibrary                    
// *********************************************************************//
  IImageDisplayInterface = interface;
  IImageDisplayInterfaceDisp = dispinterface;
  IImageDisplayInterfaceEvents = dispinterface;
 
// *********************************************************************//
// Declaration of CoClasses defined in Type Library                       
// (NOTE: Here we map each CoClass to its Default Interface)              
// *********************************************************************//
  ImageDisplayInterface = IImageDisplayInterface;
 
 
// *********************************************************************//
// Interface: IImageDisplayInterface
// Flags:     (4416) Dual OleAutomation Dispatchable
// GUID:      {E7A22657-E720-4D79-A31F-C232390DB090}
// *********************************************************************//
  IImageDisplayInterface = interface(IDispatch)
    ['{E7A22657-E720-4D79-A31F-C232390DB090}']
    procedure WorkInvoice(company: OleVariant; invType: OleVariant; out docID: OleVariant; 
                          out mStatus: OleVariant); safecall;
    procedure SaveVoucher(docID: OleVariant; docIDSeq: OleVariant; company: OleVariant; 
                          bu: OleVariant; vndrNo: OleVariant; invNo: OleVariant; 
                          invDate: OleVariant; vchrID: OleVariant; po_no: OleVariant; 
                          out mStatus: OleVariant); safecall;
    procedure UnBusyInvoice(docID: OleVariant; out mStatus: OleVariant); safecall;
    procedure GetVndrNameAddr(searchStr: OleVariant; out srchCount: OleVariant; 
                              out vndrNameAddr: OleVariant; out mStatus: OleVariant); safecall;
  end;
 
// *********************************************************************//
// DispIntf:  IImageDisplayInterfaceDisp
// Flags:     (4416) Dual OleAutomation Dispatchable
// GUID:      {E7A22657-E720-4D79-A31F-C232390DB090}
// *********************************************************************//
  IImageDisplayInterfaceDisp = dispinterface
    ['{E7A22657-E720-4D79-A31F-C232390DB090}']
    procedure WorkInvoice(company: OleVariant; invType: OleVariant; out docID: OleVariant; 
                          out mStatus: OleVariant); dispid 201;
    procedure SaveVoucher(docID: OleVariant; docIDSeq: OleVariant; company: OleVariant; 
                          bu: OleVariant; vndrNo: OleVariant; invNo: OleVariant; 
                          invDate: OleVariant; vchrID: OleVariant; po_no: OleVariant; 
                          out mStatus: OleVariant); dispid 202;
    procedure UnBusyInvoice(docID: OleVariant; out mStatus: OleVariant); dispid 203;
    procedure GetVndrNameAddr(searchStr: OleVariant; out srchCount: OleVariant; 
                              out vndrNameAddr: OleVariant; out mStatus: OleVariant); dispid 204;
  end;
 
// *********************************************************************//
// DispIntf:  IImageDisplayInterfaceEvents
// Flags:     (4096) Dispatchable
// GUID:      {A9BD6966-B3C9-42D1-BEFD-549F87868AAA}
// *********************************************************************//
  IImageDisplayInterfaceEvents = dispinterface
    ['{A9BD6966-B3C9-42D1-BEFD-549F87868AAA}']
  end;
 
// *********************************************************************//
// The Class CoImageDisplayInterface provides a Create and CreateRemote method to          
// create instances of the default interface IImageDisplayInterface exposed by              
// the CoClass ImageDisplayInterface. The functions are intended to be used by             
// clients wishing to automate the CoClass objects exposed by the         
// server of this typelibrary.                                            
// *********************************************************************//
  CoImageDisplayInterface = class
    class function Create: IImageDisplayInterface;
    class function CreateRemote(const MachineName: string): IImageDisplayInterface;
  end;
 
implementation
 
uses ComObj;
 
class function CoImageDisplayInterface.Create: IImageDisplayInterface;
begin
  Result := CreateComObject(CLASS_ImageDisplayInterface) as IImageDisplayInterface;
end;
 
class function CoImageDisplayInterface.CreateRemote(const MachineName: string): IImageDisplayInterface;
begin
  Result := CreateRemoteComObject(MachineName, CLASS_ImageDisplayInterface) as IImageDisplayInterface;
end;
 
end.
 
---------------------------------------------
 
ImageDisplayInterface.pas
unit ImageDisplayInterface;
 
{$WARN SYMBOL_PLATFORM OFF}
 
interface
 
uses
  ComObj, ActiveX, AxCtrls, Classes, ImageDisplay_TLB, StdVcl;
 
type
  TImageDisplayInterface = class(TAutoObject, IConnectionPointContainer, IImageDisplayInterface)
  private
    { Private declarations }
    FConnectionPoints: TConnectionPoints;
    FConnectionPoint: TConnectionPoint;
    FEvents: IImageDisplayInterfaceEvents;
    { note: FEvents maintains a *single* event sink. For access to more
      than one event sink, use FConnectionPoint.SinkList, and iterate
      through the list of sinks. }
  public
    procedure Initialize; override;
  protected
    { Protected declarations }
    property ConnectionPoints: TConnectionPoints read FConnectionPoints
      implements IConnectionPointContainer;
    procedure EventSinkChanged(const EventSink: IUnknown); override;
    procedure WorkInvoice(company, invType: OleVariant; out docID,
      methodStatus: OleVariant); safecall;
    procedure SaveVoucher(docID, docIDSeq, company, bu, vndrNo, invNo, invDate,
      vchrID, po_no: OleVariant; out mStatus: OleVariant); safecall;
    procedure UnBusyInvoice(docID: OleVariant; out mStatus: OleVariant);
      safecall;
    procedure GetVndrNameAddr(searchStr: OleVariant; out srchCount,
      vndrNameAddr, mStatus: OleVariant); safecall;
  end;
 
var vCompany, vDoc_id, vInvType, vDocID, vDoc_id_seq : Variant;
var vBU, vVndr_no, vInv_no, vInv_dt, vVchr_id, vPO : Variant;
var vSearchStr, vCount, vVndrNameAddr : Variant;
 
implementation
 
uses ComServ, ufrmImageDisplay;
 
procedure TImageDisplayInterface.EventSinkChanged(const EventSink: IUnknown);
begin
  FEvents := EventSink as IImageDisplayInterfaceEvents;
end;
 
procedure TImageDisplayInterface.Initialize;
begin
  inherited Initialize;
  FConnectionPoints := TConnectionPoints.Create(Self);
  if AutoFactory.EventTypeInfo <> nil then
    FConnectionPoint := FConnectionPoints.CreateConnectionPoint(
      AutoFactory.EventIID, ckSingle, EventConnect)
  else FConnectionPoint := nil;
end;
 
 
procedure TImageDisplayInterface.WorkInvoice(company, invType: OleVariant;
  out docID, methodStatus: OleVariant);
begin
  vCompany := company;
  vInvtype := invType;
  ufrmImageDisplay.WorkInvoice();
  docID := sDocID1;
  methodStatus := sStatus1;
  //hResult := S_OK;
end;
 
//   MORE MORE METHOD CALLS  REMOVED TO SHORTEN THE CODE
 
 
 
initialization
  TAutoObjectFactory.Create(ComServer, TImageDisplayInterface, Class_ImageDisplayInterface,
    ciSingleInstance, tmApartment);
end.
Attachments:
 
Screen shot of Type Library Editor for a method call
Screen shot of Type Library Editor for a method call
 
[+][-]08/30/08 11:09 AM, ID: 22352750Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08/30/08 11:16 AM, ID: 22352781Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zones: VB Script, Delphi Programming
Tags: Borland CodeGear, Delphi 7, Delphi 7
Sign Up Now!
Solution Provided By: ziolko
Participating Experts: 2
Solution Grade: A
 
[+][-]09/04/08 12:59 AM, ID: 22384982Assisted Solution

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]12/17/08 01:01 PM, ID: 23198139Administrative Comment

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091021-EE-VQP-81 / EE_QW_2_20070628