;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; 文件名: rar_path.asm
; 功 能: 获取并显示WinRAR的路径
; 作 者: Purple Endurer
; 环 境: win 2K pro + masm32 V8
; log
;------------------------------------------------------------------------------------------
; 2006.03.24 创建
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
.386
.model flat, stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\Advapi32.inc
include \masm32\include\kernel32.inc
include \masm32\include\user32.inc
includelib \masm32\lib\Advapi32.lib
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\user32.lib
GetRarPath PROTO :LPSTR
m_m2m MACRO d1, d2
push d2
pop d1
ENDM
.data
g_szTitle db "WinRAR路径", 0
g_szRegPath db "SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\WinRAR.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