Announcement

Collapse
No announcement yet.

Two Quick Questions

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Two Quick Questions

    1. How can I detect whether the OS is NT4 or Win2k (My software uses certain netapi32.dll functions so it won't run on 95/98)

    2. There are Vars like $CRLF and $Tab, these are not listed in the help file. Are they listed somewhere? are there others? I think someone used one for quotes etc

    Thanks

    ------------------

    Paul Dwyer
    Network Engineer
    Aussie in Tokyo
    (Paul282 at VB-World)

    #2
    1) Use the GetVersionEx API.

    2)

    Code:
    Equate   Character       Mnemonic
    ------   ---------       --------
    $NUL     CHR$(0)         NULL
    $BEL     CHR$(7)         Bell
    $BS      CHR$(8)         Back Space
    $TAB     CHR$(9)         Horizontal Tab
    $LF      CHR$(10)        Line Feed
    $VT      CHR$(11)        Vertical Tab
    $FF      CHR$(12)        Form Feed
    $CR      CHR$(13)        Carriage Return
    $CRLF    CHR$(13,10)     Carriage Return & Line Feed
    $EOF     CHR$(26)        End-of-File
    $ESC     CHR$(27)        Escape
    $DQ      CHR$(34)        Double-Quote
    And of course you can define your own. I often use $SPACE and several others.

    -- Eric


    ------------------
    Perfect Sync Development Tools
    Perfect Sync Web Site
    Contact Us: mailto:[email protected][email protected]</A>

    [This message has been edited by Eric Pearson (edited March 08, 2001).]
    "Not my circus, not my monkeys."

    Comment


      #3
      Hi Paul

      to answer question 1:

      Code:
      #COMPILE EXE
      #INCLUDE "win32api.inc"
       
      FUNCTION IsNt4()  AS LONG
          DIM tOsVersion AS OSVERSIONINFO
       
          tOsVersion.dwOSVersionInfoSize = SIZEOF(tOsVersion)
          IF ISTRUE(GetVersionEx(tOsVersion)) THEN
              FUNCTION = ((tOsVersion.dwPlatformId = %VER_PLATFORM_WIN32_NT) _
                          AND (tOsVersion.dwMajorVersion = 4))
          END IF
      END FUNCTION
           
      FUNCTION IsNt5()  AS LONG
          DIM tOsVersion AS OSVERSIONINFO
       
          tOsVersion.dwOSVersionInfoSize = SIZEOF(tOsVersion)
          IF ISTRUE(GetVersionEx(tOsVersion)) THEN
              FUNCTION = ((tOsVersion.dwPlatformId = %VER_PLATFORM_WIN32_NT) _
                          AND (tOsVersion.dwMajorVersion = 5))
          END IF
      END FUNCTION
       
      FUNCTION PBMAIN
          IF IsNt4() THEN
              MSGBOX "IsNt4()"
          END IF
          IF IsNt5() THEN
              MSGBOX "IstNt5()
          END IF
      END FUNCTION
      Cheers

      Florent

      ------------------

      Comment


        #4
        In regards to GetVersionEx(), are these returns correct?
        3 = Windows 95/98/ME
        4 = Windows NT
        5 = Windows 2000 and Windows XP ("Whistler")


        ------------------
        -

        Comment


          #5
          Wayne --

          No, it's more complicated than that.

          Code:
                      Platform  Major  Minor
                      --------  -----  -----
          Windows 95      1       4     0-9
          Windows 98      1       4     10+
          Windows NT4     2       4     0
          Windows 2000    2       5     0
          Windows ME      1       5     0
          XP has not been released yet, so the final values are not known.

          -- Eric


          ------------------
          Perfect Sync Development Tools
          Perfect Sync Web Site
          Contact Us: mailto:[email protected][email protected]</A>

          [This message has been edited by Eric Pearson (edited March 08, 2001).]
          "Not my circus, not my monkeys."

          Comment


            #6
            Wow,

            I go and have dinner, come back with a glass of Aussie Red and I have 4 replies!

            Eric, Your a legend, I'd buy you a beer if your were closer, thanks.

            Florent, That looks like what I need, and I can see from Erics next next post the platform version is what I need to test for too.

            Thank you all.



            ------------------

            Paul Dwyer
            Network Engineer
            Aussie in Tokyo
            (Paul282 at VB-World)

            Comment


              #7
              Checking the Windows version is probably fully adequate, in this case.

              More generally, when you're using a function that may not be available
              in all versions of Windows, the ideal technique is to use dynamic loading
              via LoadLibrary, which lets you be sure whether the function is available
              locally. This is because newer API functionality is often not strongly
              tied to the OS version, and may be available on older machines that, say,
              have the latest version of MS Internet Explorer installed. Dynamic DLL
              loading allows you to provide full functionality to everyone rather than
              making guesses about the available APIs.

              ------------------
              Tom Hanlin
              PowerBASIC Staff

              Comment


                #8
                Thanks Tom,

                I'll look into that too.

                For this project though it is not necessary, I just want to detect the OS and if it's not an NT type then disply a message and exit. 95/98/me is not supportable for this project as it involves modifying Domain users on a PDC etc.

                Thanks.

                ------------------
                Paul Dwyer
                Network Engineer
                Aussie in Tokyo

                Comment

                Working...
                X
                😀
                🥰
                🤢
                😎
                😡
                👍
                👎