/ Forside / Teknologi / Udvikling / VB/Basic / Nyhedsindlæg
Login
Glemt dit kodeord?
Brugernavn

Kodeord


Reklame
Top 10 brugere
VB/Basic
#NavnPoint
berpox 2425
pete 1435
CADmageren 1251
gibson 1230
Phylock 887
gandalf 836
AntonV 790
strarup 750
Benjamin... 700
10  tom.kise 610
Undlade at køre kode hvis det er win2000
Fra : Casper Clausen


Dato : 24-01-01 20:23

Hej NG

Hvordan kan man få sit program til at undlade at køde sin kode hvis det er
win2000? Er der noget i retning af:
#If WinNT then ???

Jeg har ikke en win2000 maskine at teste det på så jeg ville blive glad hvis
der er en der ved det.

Venlig hilsen
Casper Clausen



 
 
Helge Bjørkhaug (25-01-2001)
Kommentar
Fra : Helge Bjørkhaug


Dato : 25-01-01 09:24

"Casper Clausen" <casperc@get2net.dk> skrev i melding news:GWFb6.339$LG.6849@news.get2net.dk...
> Hej NG
>
> Hvordan kan man få sit program til at undlade at køde sin kode hvis det er
> win2000? Er der noget i retning af:
> #If WinNT then ???
>
> Jeg har ikke en win2000 maskine at teste det på så jeg ville blive glad hvis
> der er en der ved det.
>

Det enkleste er vel å bruke SysInfo ocx'en (Startup object _bør_ da være en form).
If SysInfo1.OSPlatform = 2 And SysInfo1.OSVersion = 5 Then
Msgbox "Programmet kan ikke kjøres på WIN2000!!!"
Unload Me
End

Si i fra hvis du vil ha en API versjon....

Mvh,

Helge



N/A (25-01-2001)
Kommentar
Fra : N/A


Dato : 25-01-01 21:42



Helge Bjørkhaug (25-01-2001)
Kommentar
Fra : Helge Bjørkhaug


Dato : 25-01-01 21:42

"Casper Clausen" <casperc@get2net.dk> wrote in message
news:DiWb6.181$_N1.9204@news.get2net.dk...
> En API version den kune jeg da også godt tænke mig at se
>
[snip]

Putt dette i en Module og sett "Startup Object" til "Sub Main" i "Project Properties";
Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (lpVersionInformation As
OSVERSIONINFO) As Long
Type OSVERSIONINFO
dwOSVersionInfoSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildNumber As Long
dwPlatformId As Long
szCSDVersion As String * 128
End Type
Sub Main()
Dim OSInfo As OSVERSIONINFO, PId As String, Ret as Long
OSInfo.dwOSVersionInfoSize = Len(OSInfo)
Ret = GetVersionEx(OSInfo)
If Ret = 0 Then MsgBox "Error Getting Version Information": Exit Sub
If OSInfo.dwPlatformId = 2 And OSInfo.dwMajorVersion = 5 Then
MsgBox "Programmet er ikke testet ut under WIN2000!!!"
End
Else
MsgBox "Start Default Form her, f.eks Form1.Show"
End If
End Sub

Mvh,

Snutten



savage2000@my-deja.c~ (26-01-2001)
Kommentar
Fra : savage2000@my-deja.c~


Dato : 26-01-01 16:25

Og for andre vindows versjoner kan du bruke dette utklippet (fra vbcode
magician)

This tip will show you how to identify the type of OS
(Windows95/98/ME/NT/2000) and any installed service pack information.
If also shows how to retrieve the version info string (Major, Minor and
Build info).

To try this sample start a new project and add a module to the project
(Module1). To the form (Form1) add to labels (named Label1 and Label2)
plus a Button (Button1). Then add this code.




Add this code to a Module:

Option Explicit

Public Declare Function GetVersionEx Lib "kernel32" Alias _
"GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As Long

Public Type OSVERSIONINFO
dwOSVersionInfoSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildNumber As Long
dwPlatformId As Long
szCSDVersion As String * 128 ' Maintenance string for PSS usage
End Type

' dwPlatforID Constants
Public Const VER_PLATFORM_WIN32s = 0
Public Const VER_PLATFORM_WIN32_WINDOWS = 1
Public Const VER_PLATFORM_WIN32_NT = 2
'-- End --'


Add this code to a form:

Private Sub Form_Load()

Dim tOSVer As OSVERSIONINFO

' First set length of OSVERSIONINFO
' structure size
tOSVer.dwOSVersionInfoSize = Len(tOSVer)
' Get version information
GetVersionEx tOSVer
' Determine OS type
With tOSVer

Select Case .dwPlatformId
Case VER_PLATFORM_WIN32_NT
' This is an NT version (NT/2000)
' If dwMajorVersion >= 5 then
' the OS is Win2000
If .dwMajorVersion >= 5 Then
Label1.Caption = "Windows 2000"
Else
Label1.Caption = "Windows NT"
End If
Case Else
' This is Windows 95/98/ME
If .dwMajorVersion >= 5 Then
Label1.Caption = "Windows ME"
ElseIf .dwMajorVersion = 4 And .dwMinorVersion > 0 Then
Label1.Caption = "Windows 98"
Else
Label1.Caption = "Windows 95"
End If
End Select
' Check for service pack
Label1.Caption = Label1.Caption & " " & Left(.szCSDVersion, _
InStr(1, .szCSDVersion, Chr$(0)))
' Get OS version
Label2.Caption = "Version: " & .dwMajorVersion & "." & _
.dwMinorVersion & "." & .dwBuildNumber

End With

End Sub
Private Sub Command1_Click()
Unload Me
End Sub
'-- End --'


Run the application by pressing F5. Label1 will hold OS type and
service pack info. Label2 will hold the version string.








In article <Pc0c6.1080$jQ1.16802@news1.oke.nextra.no>,
"Helge Bjørkhaug" <snutten@techie.online.no> wrote:
> "Casper Clausen" <casperc@get2net.dk> wrote in message
> news:DiWb6.181$_N1.9204@news.get2net.dk...
> > En API version den kune jeg da også godt tænke mig at se
> >
> [snip]
>
> Putt dette i en Module og sett "Startup Object" til "Sub Main"
i "Project Properties";
> Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA"
(lpVersionInformation As
> OSVERSIONINFO) As Long
> Type OSVERSIONINFO
> dwOSVersionInfoSize As Long
> dwMajorVersion As Long
> dwMinorVersion As Long
> dwBuildNumber As Long
> dwPlatformId As Long
> szCSDVersion As String * 128
> End Type
> Sub Main()
> Dim OSInfo As OSVERSIONINFO, PId As String, Ret as Long
> OSInfo.dwOSVersionInfoSize = Len(OSInfo)
> Ret = GetVersionEx(OSInfo)
> If Ret = 0 Then MsgBox "Error Getting Version Information": Exit
Sub
> If OSInfo.dwPlatformId = 2 And OSInfo.dwMajorVersion = 5 Then
> MsgBox "Programmet er ikke testet ut under WIN2000!!!"
> End
> Else
> MsgBox "Start Default Form her, f.eks Form1.Show"
> End If
> End Sub
>
> Mvh,
>
> Snutten
>
>


Sent via Deja.com
http://www.deja.com/

Søg
Reklame
Statistik
Spørgsmål : 177501
Tips : 31968
Nyheder : 719565
Indlæg : 6408527
Brugere : 218887

Månedens bedste
Årets bedste
Sidste års bedste