程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> 匯編語言 >> 用MASM32編程獲取並顯示WinRAR的路徑

用MASM32編程獲取並顯示WinRAR的路徑

編輯:匯編語言

;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; 文件名: rar_path.asm
; 功 能: 獲取並顯示WinRAR的路徑
; 作 者: Purple Endurer
; 環 境: win 2K pro + masm32 V8
; log
;------------------------------------------------------------------------------------------
; 2006.03.24 創建
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
.386
.model flat, stdcall
option casemap:none
include masm32includewindows.inc
include masm32includeAdvapi32.inc
include masm32includekernel32.inc
include masm32includeuser32.inc
includelib masm32libAdvapi32.lib
includelib masm32libkernel32.lib
includelib masm32libuser32.lib
GetRarPath PROTO :LPSTR
m_m2m MACRO d1, d2
  push d2
  pop d1
ENDM
.data
g_szTitle   db "WinRAR路徑", 0
g_szRegPath db "SOFTWAREMicrosoftWindowsCurrentVersionApp PathsWinRAR.exe", 0
g_szFailRegOpenKeyEx db "RegOpenKeyEx失敗!", 0
g_szFailRegQueryValueEx db "RegQueryValueEx失敗!", 0
g_szValueName db "Path", 0
.data?
g_szRarPath db 256 dup(?)
g_hRegKey4IE HKEY  ?
.code
start:
    invoke GetRarPath, ADDR g_szRarPath
    .if eax==1
      mov eax, OFFSET g_szFailRegOpenKeyEx
    .elseif eax==2
      mov eax, OFFSET g_szFailRegQueryValueEx
    .else
      mov eax, OFFSET g_szRarPath
    .endif
    invoke MessageBox, NULL, eax, OFFSET g_szTitle, MB_OK
    invoke ExitProcess,NULL
GetRarPath PROC lpszRarPath: LPSTR
  LOCAL dwcbData: dword
;    LONG RegOpenKey(
;      HKEY hKey,  // handle of open key
;      LPCTSTR lpSubKey,  // address of name of subkey to open
;      PHKEY phkResult  // address of handle of open key
;    );
  invoke RegOpenKey, HKEY_LOCAL_MACHINE, ADDR g_szRegPath, ADDR g_hRegKey4IE
  .if eax!=ERROR_SUCCESS
    m_m2m eax, 1
    ret
  .endif
;  LONG RegQueryValueEx(
;    HKEY hKey,     // 1.handle of key to query
;    LPTSTR lpValueName, // 2.address of name of value to query
;    LPDWORD lpReserved, // 3.reserved
;    LPDWORD lpType,  // 4.address of buffer for value type
;    LPBYTE lpData,   // 5.address of data buffer
;    LPDWORD lpcbData  // 6.address of data buffer size
;  );
  m_m2m dwcbData, SIZEOF g_szRarPath
  invoke RegQueryValueEx, g_hRegKey4IE, ADDR g_szValueName, NULL, NULL, ADDR g_szRarPath, ADDR dwcbData
  .if eax!=ERROR_SUCCESS
    m_m2m eax, 2
  .else
    xor eax, eax
  .endif
; LONG RegCloseKey(
;  HKEY hKey  // handle of key to close 
; );
  invoke RegCloseKey, g_hRegKey4IE
  ret
GetRarPath ENDP
end start

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved