丁香婷婷网,黄色av网站裸体无码www,亚洲午夜无码精品一级毛片,国产一区二区免费播放

現(xiàn)在位置:范文先生網(wǎng)>理工論文>計算機信息技術(shù)>在VFP中獲取Windows注冊信息的方法

在VFP中獲取Windows注冊信息的方法

時間:2023-02-21 00:12:04 計算機信息技術(shù) 我要投稿
  • 相關(guān)推薦

在VFP中獲取Windows注冊信息的方法

葛曉濱(中國國際電子商務(wù)中心安徽代表處)
關(guān)鍵詞

 

    在Visual Foxpro軟件的程序設(shè)計中,我們經(jīng)常需要關(guān)注其程序設(shè)計的環(huán)境,尤其是獲得Windows軟件系統(tǒng)注冊的用戶名及單位名稱。為此我們設(shè)計了一個在Windows 3.X、Window 95、Windows 98Windows NT 4.0環(huán)境下均通用的一個子程序,可以滿足上述的需要。

 

#DEFINE MACHINE_ID -2147483646

#DEFINE VER_PATH "Software\Microsoft\Windows\CurrentVersion"

 

*--聲明Windows API 函數(shù)

DECLARE INTEGER GetProfileString IN Win32API AS GetProStr ;

String cSection, String cKey, String cDefault, ;

String @cBuffer, Integer nBufferSize

 

*-- 聲明注冊表函數(shù)

DECLARE Integer RegOpenKeyEx IN Win32API ;

Integer nKey, String @cSubKey, Integer nReserved,;

Integer nAccessMask, Integer @nResult

 

DECLARE Integer RegQueryValueEx IN Win32API ;

Integer nKey, String cValueName, Integer nReserved,;

Integer @nType, String @cBuffer, Integer @nBufferSize

 

DECLARE Integer RegCloseKey IN Win32API ;

Integer nKey

 

*-- 初始化DLL調(diào)用變量

OutBuffer = SPACE(128)

STORE 0 TO Reserved, Result, Type

BufferSize = LEN(OutBuffer)

 

STORE "" TO OutUser, OutCompany

 

*-- 通過VFP的OS()函數(shù)判定當(dāng)前操作系統(tǒng)類型

DO CASE

CASE UPPER(OS()) = "WINDOWS 4"

*-- 系統(tǒng)為Windows 95 以上版本

Error = RegOpenKeyEx(MACHINE_ID, VER_PATH, ;

Reserved, 1, @Result)

 

IF Error = 0

Type = 0

OutBuffer = SPACE(128)

BufferSize = LEN(OutBuffer)

Error = RegQueryValueEx(Result, "RegisteredOwner", Reserved, ;

@Type, @OutBuffer, @BufferSize)

 

IF Error = 0 AND OutBuffer <> CHR(0)

OutUser = LEFT(OutBuffer, BufferSize - 1)

ENDIF

 

Type = 0

OutBuffer = SPACE(128)

BufferSize = LEN(OutBuffer)

Error = RegQueryValueEx(Result, "RegisteredOrganization", Reserved, ;

@Type, @OutBuffer, @BufferSize)

 

IF Error = 0 AND OutBuffer <> CHR(0)

OutCompany = LEFT(OutBuffer, BufferSize - 1)

ENDIF

ENDIF

=RegCloseKey(Result)

 

CASE UPPER(OS()) = "WINDOWS NT"

*-- 系統(tǒng)為Windows NT

Error = RegOpenKeyEx(MACHINE_ID, KEY_SHARED_TOOLS_LOCATION, ;

Reserved, 1, @Result)

 

IF Error = 0

Type = 0

OutBuffer = SPACE(128)

BufferSize = LEN(OutBuffer)

Error = RegQueryValueEx(Result, "RegisteredOwner", Reserved, ;

@Type, @OutBuffer, @BufferSize)

 

IF Error = 0 AND OutBuffer <> CHR(0)

OutUser = LEFT(OutBuffer, BufferSize - 1)

ENDIF

 

Type = 0

OutBuffer = SPACE(128)

BufferSize = LEN(OutBuffer)

Error = RegQueryValueEx(Result, "RegisteredOrganization", Reserved, ;

@Type, @OutBuffer, @BufferSize)

 

IF Error = 0 AND OutBuffer <> CHR(0)

OutCompany = LEFT(OutBuffer, BufferSize - 1)

ENDIF

ENDIF

=RegCloseKey(Result)

 

OTHERWISE

*-- 系統(tǒng)為Windows 3.X 版本

OutRetVal = GetProStr("MS USER INFO", "DEFNAME", "", @OutBuffer, BufferSize)

OutUser = LEFT(OutBuffer, OutRetVal)

 

OutRetVal = GetProStr("MS USER INFO", "DEFCOMPANY", "", @OutBuffer,BufferSize)

OutCompany = LEFT(OutBuffer, OutRetVal)

 

ENDCASE

 

If Error = 0

=MessageBox("用戶:" + OutUser + Chr(13) + "單位:" + OutCompany)

Else

=MessageBox("未找到用戶及單位。")

Endif


【在VFP中獲取Windows注冊信息的方法】相關(guān)文章:

Internet中的藥學(xué)信息資源及獲取方法08-05

論小數(shù)教學(xué)中培養(yǎng)學(xué)生獲取和處理信息的能力08-07

從失誤中獲取機遇的國旗下講話08-24

[國旗下講話]從失誤中獲取機遇08-17

從失誤中獲取機遇國旗下講話07-20

信息技術(shù)教學(xué)中的問題及改進方法08-07

在Delphi中巧用Windows 的API函數(shù)08-06

在信息課中嘗試“任務(wù)驅(qū)動”教學(xué)方法08-07

利用注冊表對WINDOWS 98進行管理與維護08-06