Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
CDO Emulation of VBasic value NOTHING Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
23-Oct-02
Category
OLE
Language
Delphi 5.x
Views
106
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Mike Heydon

I am currently writing a class that encapsulates the CDO (Collaboration Data 
Objects) in Delphi. For those of you who do not know what CDO is, it is a library 
that allows acces to MS-Exchange and Outlook folders,messages etc. much in the way 
of MAPI. 

Answer:

One problem that kept cropping up from the examples in CDO.HLP was the use of 
something called "NOTHING" in the VB examples. 

eg. 

   Set objFolder = objSession.GetFolder(strFolderID) 

    If objFolder Is Nothing Then 
        Set objMessages = Nothing 
        MsgBox "Unable to retrieve folder with specified ID" 
        Exit Function 
    End If 

This is not "VARNULL",'VAREMPTY" or even "UNASSIGNED" in Delphi. Trying "if 
obFolder = VarNull" or any of above results in invalid typecast errors as do trying 
to compare to NIL.

What is it then ..... It is an IDispatch type which is set to NIL

The following 2 functions will emulate the behaviour of VB's NOTHING in Delphi.
1   
2   // ===================================
3   // Emulate VB function IS NOTHING
4   // ===================================
5   
6   function IsNothing(Obj: OleVariant): boolean;
7   begin
8     Result := IDispatch(Obj) = nil;
9   end;
10  
11  // ============================================
12  // Emulate VB function VarX := Nothing
13  // ============================================
14  
15  function varNothing: IDispatch;
16  var
17    Retvar: IDispatch;
18  begin
19    Retvar := nil;
20    Result := Retvar;
21  end;
22  
23  -------------------------------------------------------------------------- 
24  Now the VBasic example can translate to ... 
25  
26  var
27    objFolder, objMessages: OleVariant;
28  
29    objFolder := objSession.GetFolder(strFolderID);
30  
31  if IsNothing(objFolder) then
32  begin
33    objMessages := varNothing;
34    ShowMessage('Unable to retrieve folder with specified ID');
35    exit;
36  end;


For more information on CDO see CDO.HLP (From MS-Exchange CD) or Web Site 
http://www.cdolive.com/exchange2000.htm

			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC