Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Register OCX automatically
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00526982
Message ID:
00527925
Views:
31
>Nick,
>Is there a way programaically to determine if App is running on Window 95/98/2000 or nt
>
>I would want My app to say :
>
>If MyOS = 95 or 98,then RegisterControl("C:\Windows\system\comctl32.ocx)
>If Myos = 'NT',then RegisterControl("C:\Windows\System32\Comctl32.ocx)
>If MyOs = '2000' then RegisterControl("C:\Windows\xxxxxx\Comct132.ocx)

OS() function in VFP returns the name of current operating system. But it is not enough. To make it work reliable, you should retrieve the exacts path of your Windows and system directory through Win API functions GetWindowsDirectory() and GetSystemDirectory(), because on different PCs Windows may be in different drive/directory, especially if you have multiple OS on one PC installed.
For example, I upgraded my home PC from Windows 98 to Windows 2000, and I have C:\Windows and C:\Windows\System32 directories instead of usual C:\WINNT\System32, if I would do the clean install of Windows 2000.

>Or does the .OCX 'have' to be in a specified folder.
>If I always put it into the Folder of my App and then I can always just:
>
> llRegistered=RegisterControl("MyDrive:\MyFolder\MyOcx.ocx")
>

You may register your OCX in the directory other than Windows\System or Winnt\System32, etc., it is just that is the usual location for most of OCX and DLL files.
Then again, you might end up with the same name OCX (but different versions) registered in different directories which may cause another app to fail. Or, you made your VFP app working with certain version of COMCTL32.OCX in Windows\System directory, and then somebody installs, say VB6 on one PC, which may replace your OCX with different version and BANG! - your app suddenly fails on one PC. That is known as "DLL hell". :)

>
>>Yes, it should work in any version, just the location of controls may be different, for example:
>>llRegistered = RegisterControl("c:\windows\system\comctl32.ocx")
>>llRegistered = RegisterControl("c:\winnt\system32\comctl32.ocx")
>>
>>
>>>Nick, thanks for your reply
>>>
>>>I have had a quick look at the URL and did not see any refernece to OS
>>>
>>>Do you know if the code works in Win 95/98/2000 and NT ?
>>>
>>>Regards,
>>>
>>>Gerard
>>>
>>>
>>>
>>>>>Is there a way of registering a component automatically ?
>>>>>What I would like to do is:
>>>>>
>>>>>From my Main .PRG file:
>>>>>-----------------------
>>>>>
>>>>>If MyOcx is not already registered
>>>>> Register MyOcx now
>>>>>Endif
>>>>>
>>>>>I will also need to know if the system is Win95 or WinNT (If it matters)
>>>>>
>>>>>Anybody any ideas on this ?
>>>>>
>>>>>Regards,
>>>>>
>>>>>Gerard
>>>>
>>>>Gerard, see "How to register/unregister an OCX/ActiveX programatically" FAQ#7699
Nick Neklioudov
Universal Thread Consultant
3 times Microsoft MVP - Visual FoxPro

"I have not failed. I've just found 10,000 ways that don't work." - Thomas Edison
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform