Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Checking for Error while creating an Object
Message
From
19/12/2002 11:28:25
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
19/12/2002 11:07:58
Sony Joseph
Dovenmuehle Mortgage Inc
Schaumburg, Illinois, United States
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Miscellaneous
Thread ID:
00734510
Message ID:
00734520
Views:
17
>Hi,
>
>I would like to trap the error if an object is not successfully created.
>For Eg.
>owsh=CreateObject("Scriping.FilesystemObject")
>IF Vartype(oWsh)<>"O"
> =MessageBox("Not created")
>ENDIF
>In this case, if the system can not create the object, it would yell saying, 'Class definition 'Scriping.FilesystemObject' is not found'. So, even before I can check it's type, the error comes up. Do I have to use the error routine to trap the error, or is there a more direct way to check for the error here?
>
>TIA
if !_IsClassRegistered("Scripting.FileSystemObject")
 MessageBox("WSH not installed")
endif

function _IsClassRegistered
lparameters tcClass
#DEFINE HKEY_CLASSES_ROOT    -2147483648
#DEFINE ERROR_SUCCESS		0	&& OK

DECLARE Integer RegOpenKey IN Win32API ;
	Integer nHKey, String @cSubKey, Integer @nResult

DECLARE Integer RegCloseKey IN Win32API ;
	Integer nHKey

local lnKey
lnKey = 0
llRetVal = ( RegOpenKey(HKEY_CLASSES_ROOT, tcClass, @lnKey) = ERROR_SUCCESS )
if llRetVal
  RegCloseKey(lnKey)
endif
*vfp7
*CLEAR DLLS 'RegOpenKey', 'RegCloseKey'
return llRetVal
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform