RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
ComObj.OleCheck Function

Throws an EOleSysError exception if the result code indicates an error.

Pascal
procedure OleCheck(Result: HResult);
C++
OleCheck(HRESULT Result);

OleCheck is used to wrap many COM routines, so that if that routine fails, users will have an opportunity to handle it in the resulting exception that is raised. 

If ECode is a value less than zero, OleCheck raises an EOleSysError exception that specifies the error code.  

C++ Examples: 

 

/*
The following example manufactures a GUID and displays it in
a dialog box after translating it to a string.
*/
#include <ActiveX.hpp>
#include <ComObj.hpp>
#include <Sysutils.hpp>

void __fastcall TForm1::Button1Click(TObject *Sender)
{
    TGUID g;
    OleCheck(CoCreateGuid(&g));
    ShowMessage(Sysutils::GUIDToString(g));
}

 

Delphi Examples: 

{
The following example manufactures a GUID and displays it in
a dialog box after translating it to a string.
} 
uses ActiveX, ComObj;
procedure TForm1.Button1Click(Sender: TObject);
var
  G: TGUID;
begin
  OleCheck(CoCreateGuid(G));
  ShowMessage(SysUtils.GUIDToString(G));
end;

 

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!