Getting OS information 
Author Message
 Getting OS information

Can anyone tell me how I would go about making my app know the
difference between windows95/98 and windowsNT4? I found several
different ways of checking the version with my app in the KB, but now
way of making it so that my app can automatically tell the difference,
and then do something totally different.

I also have one other problem. I am making a program that writes a
file to the windows folder. This is fine, I can do that. But I need to
know how to determine where the windows directory is automatically.
Right now my program writes the file (in code) to C:\WINDOWS....  but
not everyone installs Windows to their C drive. I need to know how to
make my app "find" where Windows is installed.

Many thanks in advance,
That Dude



Tue, 05 Dec 2000 03:00:00 GMT  
 Getting OS information

Use
    GetWindowsDirectory
API for Windows and
    GetSystemDirectory
for  Windows\System directory

They declared as
Declare Function GetWindowsDirectory Lib "kernel32" Alias
"GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As
Long
Declare Function GetSystemDirectory Lib "kernel32" Alias
"GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As
Long

Use
    Public Const C_MAXPATH = 260
for the maximum path length

Quote:

>Can anyone tell me how I would go about making my app know the
>difference between windows95/98 and windowsNT4? I found several
>different ways of checking the version with my app in the KB, but now
>way of making it so that my app can automatically tell the difference,
>and then do something totally different.

>I also have one other problem. I am making a program that writes a
>file to the windows folder. This is fine, I can do that. But I need to
>know how to determine where the windows directory is automatically.
>Right now my program writes the file (in code) to C:\WINDOWS....  but
>not everyone installs Windows to their C drive. I need to know how to
>make my app "find" where Windows is installed.

>Many thanks in advance,
>That Dude



Tue, 05 Dec 2000 03:00:00 GMT  
 Getting OS information

Quote:

>I also have one other problem. I am making a program that writes a
>file to the windows folder. This is fine, I can do that. But I need to
>know how to determine where the windows directory is automatically.
>Right now my program writes the file (in code) to C:\WINDOWS....  but
>not everyone installs Windows to their C drive. I need to know how to
>make my app "find" where Windows is installed.

Windows adds an environment variable which you can use. If you type SET
at the DOS-prompt, you'll see it: windir=C:\WINDOWS

To write a file to this directory, you just open a file named:
"%windir%\myfile.txt"

If your windows directory is called C:\WINDOWS, it will create a file
called C:\WINDOWS\MYFILE.TXT. If you're using C:\WIN95, for example,
a file named C:\WIN95\MYFILE.TXT will be created instead.

THis works with DOS Basics -- I'm not absolutely certain Windows Basic's
would work the same way, but there's only one way to find out...
--
Marc van den Dikkenberg
-----------------------
The powerbasic Archives
http://www.xs4all.nl/~excel/pb.html



Wed, 06 Dec 2000 03:00:00 GMT  
 Getting OS information

Use the following API's to retrieve the Windows directory and to identify
the current OS version.
Help Files tell use to use the GetVersionEx with the OSVERSIONINFO type
structure other than the GetVersion API. I've tried using it only to receive
a compile error ("user defined types cannot be passed ByVal"). I've switched
over to ByRef with the return being all zeros, possible due to my
installation of Win95 Desktop Update. Anyway, I think this should do the
job.

Private Declare Function GetWindowsDirectory Lib "kernel32" Alias
"GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As
Long

Private Declare Function GetVersion Lib "kernel32" () As Long

Private Const VER_PLATFORM_WIN32_NT = 2
Private Const VER_PLATFORM_WIN32_WINDOWS = 1
Private Const VER_PLATFORM_WIN32s = 0

Dim WinDir As String         'Buffer to hold WINDOW dir.
Dim WinDirLen As Long    'Length of buffer
Dim winRC As Long           'GetWindowsDirectory Return Code
Dim verRC As Long           'GetVersion return code

WinDir = Space(255)
WinDirLen = Len(WinDir)

wRC = GetWindowsDirectory(WinDir, WinDirLen)

verRC = GetVersion()

    Select Case verRC
        Case VER_PLATFORM_WIN32_NT
            'Do something here.
        Case VER_PLATFORM_WIN32_WINDOWS
            'Do something
        Case VER_PLATFORM_WIN32s
            'Do something
        Case Else
            'Some other version not recognized.
    End Select

Quote:

>Can anyone tell me how I would go about making my app know the
>difference between windows95/98 and windowsNT4? I found several
>different ways of checking the version with my app in the KB, but now
>way of making it so that my app can automatically tell the difference,
>and then do something totally different.

>I also have one other problem. I am making a program that writes a
>file to the windows folder. This is fine, I can do that. But I need to
>know how to determine where the windows directory is automatically.
>Right now my program writes the file (in code) to C:\WINDOWS....  but
>not everyone installs Windows to their C drive. I need to know how to
>make my app "find" where Windows is installed.

>Many thanks in advance,
>That Dude



Wed, 06 Dec 2000 03:00:00 GMT  
 Getting OS information

Thanks!

That Dude



Quote:

>>I also have one other problem. I am making a program that writes a
>>file to the windows folder. This is fine, I can do that. But I need to
>>know how to determine where the windows directory is automatically.
>>Right now my program writes the file (in code) to C:\WINDOWS....  but
>>not everyone installs Windows to their C drive. I need to know how to
>>make my app "find" where Windows is installed.

>Windows adds an environment variable which you can use. If you type SET
>at the DOS-prompt, you'll see it: windir=C:\WINDOWS

>To write a file to this directory, you just open a file named:
>"%windir%\myfile.txt"

>If your windows directory is called C:\WINDOWS, it will create a file
>called C:\WINDOWS\MYFILE.TXT. If you're using C:\WIN95, for example,
>a file named C:\WIN95\MYFILE.TXT will be created instead.

>THis works with DOS Basics -- I'm not absolutely certain Windows Basic's
>would work the same way, but there's only one way to find out...

That Dude?

"What, me worry?"
    -Alfred E. Newman

To email me, remove "SPAM SUCKS" from my
email address.



Thu, 07 Dec 2000 03:00:00 GMT  
 Getting OS information

Thanks a million!

That Dude

On Sat, 20 Jun 1998 11:44:09 -0400, "Michael Petrynka"

Quote:

>Use the following API's to retrieve the Windows directory and to identify
>the current OS version.
>Help Files tell use to use the GetVersionEx with the OSVERSIONINFO type
>structure other than the GetVersion API. I've tried using it only to receive
>a compile error ("user defined types cannot be passed ByVal"). I've switched
>over to ByRef with the return being all zeros, possible due to my
>installation of Win95 Desktop Update. Anyway, I think this should do the
>job.

>Private Declare Function GetWindowsDirectory Lib "kernel32" Alias
>"GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As
>Long

>Private Declare Function GetVersion Lib "kernel32" () As Long

>Private Const VER_PLATFORM_WIN32_NT = 2
>Private Const VER_PLATFORM_WIN32_WINDOWS = 1
>Private Const VER_PLATFORM_WIN32s = 0

>Dim WinDir As String         'Buffer to hold WINDOW dir.
>Dim WinDirLen As Long    'Length of buffer
>Dim winRC As Long           'GetWindowsDirectory Return Code
>Dim verRC As Long           'GetVersion return code

>WinDir = Space(255)
>WinDirLen = Len(WinDir)

>wRC = GetWindowsDirectory(WinDir, WinDirLen)

>verRC = GetVersion()

>    Select Case verRC
>        Case VER_PLATFORM_WIN32_NT
>            'Do something here.
>        Case VER_PLATFORM_WIN32_WINDOWS
>            'Do something
>        Case VER_PLATFORM_WIN32s
>            'Do something
>        Case Else
>            'Some other version not recognized.
>    End Select


>>Can anyone tell me how I would go about making my app know the
>>difference between windows95/98 and windowsNT4? I found several
>>different ways of checking the version with my app in the KB, but now
>>way of making it so that my app can automatically tell the difference,
>>and then do something totally different.

>>I also have one other problem. I am making a program that writes a
>>file to the windows folder. This is fine, I can do that. But I need to
>>know how to determine where the windows directory is automatically.
>>Right now my program writes the file (in code) to C:\WINDOWS....  but
>>not everyone installs Windows to their C drive. I need to know how to
>>make my app "find" where Windows is installed.

>>Many thanks in advance,
>>That Dude



Sat, 09 Dec 2000 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Getting OS information

2. Getting OS information

3. Getting OS information of a network machine (2)

4. Getting OS information of a network machine

5. Diff between Pocket PC OS / Handled PC OS/ Embedded NT OS

6. APIs for getting the OS??

7. Getting OS version

8. Getting the OS ???

9. English OS to Japanese OS

10. Getting the Resource Email Information

11. Getting information out of a UML Diagram

12. Getting Information on a DLL'd date or version using VBA

 

 
Powered by phpBB® Forum Software