Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Checking for COM server ?
Message
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Divers
Thread ID:
00798846
Message ID:
00798892
Vues:
26
Thank you for the explanation, Sergey. One more reason to move up to VFP 8. Which I plan to do, anyway.

>Dmitry,
>
>The brackets are needed because TYPE() function evaluates it's argument and the error isn't generated because TYPE() function intercepts it and returns "U". It would be quite easy to do in VFP8.
TRY
>  poGpmPager = createobj("Pager.Send")
>CATCH
>  =messagebox( "problem" )
>ENDTRY
In previous version you'll have to use local error handler to do the same.
>
>>Sergey,
>>I have a follow-up question. Your suggestion to check for the COM server works very well, but I was wondering about something.
>>
>>Initially, before I posted a message here, I was checking for COM server as follows:
>>
>>
>>poGpmPager = createobj("Pager.Send")
>>if !type("poGpmPager") = "O" or isnull( poGpmPager )
>>   =messagebox( "problem" )
>>endif
>>
>>
>>But it didn't work and I was getting error on "createobj" line.
>>
>>I am wondering, why the syntax above does not work but when you add square brackets [] around createbobj, it works?
>>
>>With addition of your code, now the program creats the object twice: one time to check for COM server registration and another one for actually creating the object. It's not a big deal but I thought that it would be nice to improve the speed by combining both in one. Actually as I type this message I am thinking that maybe I should use brackets [] when creating the object to make it all in one call. I will try it now.
>>
>>>You're welcome.
>>>
>>>>Thank you very much for your help, Sergey.
>>>>
>>>>>Dmitry,
>>>>>
>>>>>
? TYPE([CREATEOBJECT("mydll.mycomclass")]) = "O"     && will return .T. if it is registeredf
>>>>>
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform