请教api高手,怎么区别我的操作系统是98还是2000?

CNer 2001-12-09 05:34:45
我在调用api时,
常发现有的api比如:getwindowsdirectory
在98下可以正确声明,
在2000下,就说找不到入口点,
怎么声名api可以让我的程序在98和2000下都能正确运行呢?

...全文
66 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
NowCan 2001-12-09
  • 打赏
  • 举报
回复
不可能,那个函数在2000下绝对可以用。
Public Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Raphael_CSDN 2001-12-09
  • 打赏
  • 举报
回复
win2000比win98都了一些api函数!
karma 2001-12-09
  • 打赏
  • 举报
回复
use this API to find out whether you are using win98 or 2000:
BOOL GetVersionEx( LPOSVERSIONINFO lpVersionInformation);

You should use TCHAR.H and related data types to declare your API
T2 2001-12-09
  • 打赏
  • 举报
回复
我在2000下调试的程序在98下没问题.
wefhl 2001-12-09
  • 打赏
  • 举报
回复
Declare Function GetVersion Lib "kernel32" Alias "GetVersion" () As Long
说明
判断当前运行的Windows和DOS版本
返回值
Long,低16位包含了windows版本;低字节包含了主版本号(3代表windows 3.10,4代表nt 4.0);高字节包含了两个数位的辅助版本号(10代表windows 3.10,95代表windows 95)。高16位则包含了平台信息。针对windows NT,高位设为0;针对windows for workgroups上运行的Win32s,则高位为1
注解
在win32下,最好换用GetVersionEx函数。在win32下,高字不会返回DOS版本

Bardo 2001-12-09
  • 打赏
  • 举报
回复
Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As Long


Private Function fGetOSVersion()
Dim os As OSVERSIONINFO
'
' Returns True if Win98 or Win2000
'
fGetOSVersion = False
With os
.dwOSVersionInfoSize = Len(os)
Call GetVersionEx(os)

' Windows 2000
If .dwMajorVersion > 4 Then fGetOSVersion = True

If .dwMajorVersion = 4 And _
.dwPlatformID = VER_PLATFORM_WIN32_WINDOWS And _
.dwMinorVersion > 0 Then
fGetOSVersion = True
End If
End With
End Function

1,486

社区成员

发帖
与我相关
我的任务
社区描述
VB API
社区管理员
  • API
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧