我在網路上找到MSN的密碼顯示器(C語言) http://www.bernardotti.it/portal/showthread.php?t=1875
以下是我自己改成Delphi的源碼...program Project1;{$APPTYPE CONSOLE}uses
SysUtils,
Windows;{ 資料結構 }
type
TCREDENTIAL_ATTRIBUTEA = record
Keyword: LPSTR;
Flags: DWORD;
ValueSize: DWORD;
Value: PByte;
end;
PCREDENTIAL_ATTRIBUTEA = ^TCREDENTIAL_ATTRIBUTEA; TCREDENTIALA = record
Flags: DWORD;
PType: DWORD; //在C語言中宣告為Type, 在Delphi為關鍵字, 因此以PType代替
TargetName: LPSTR;
Comment: LPSTR;
LastWritten: FILETIME;
CredentialBlobSize: DWORD;
CredentialBlob: PByte;
Persist: DWORD;
AttributeCount: DWORD;
Attributes: PCREDENTIAL_ATTRIBUTEA;
TargetAlias: LPSTR;
UserName: LPSTR;
end;
PCREDENTIALA = array of ^TCREDENTIALA;type
typeCredFree = function (Buffer: Pointer): BOOL;function CredEnumerate(Filter: LPCSTR; Flags: DWORD; var Count: DWORD; var Credential: PCREDENTIALA): BOOL; stdcall; external 'advapi32.dll' Name 'CredEnumerateA';var
CredentialCollection: PCREDENTIALA;
hAdvapi32DLL: HWND;
dwCount: DWORD;
dwTempIndex: DWORD;
bOK: Boolean; pfCredFree: typeCredFree;
begin
hAdvapi32DLL := 0;
dwCount := 0;
dwTempIndex := 0;
bOK := false;
pfCredFree := nil;
repeat
begin
hAdvapi32DLL := LoadLibrary('advapi32.dll');
if (hAdvapi32DLL = 0) then
begin
writeln('載入 advapi32.dll 發生錯誤');
exit;
end;
@pfCredFree := GetProcAddress(hAdvapi32DLL, 'CredFree');
if (@pfCredFree = nil) then
begin
writeln('載入 Cred API 時發生錯誤');
exit;
end;
bOK := CredEnumerate('WindowsLive:name=*', 0, dwCount, CredentialCollection);
if (bOK = false) then
begin
writeln('列舉安全憑證時發生錯誤');
exit;
end;
for dwTempIndex := 0 to dwCount - 1 do
begin
writeln('Username : ' + CredentialCollection[dwTempIndex].UserName);
writeln('Password : ' + PChar(Pointer(CredentialCollection[dwTempIndex].CredentialBlob)));
end;
pfCredFree(CredentialCollection);
end
until (true);
if (hAdvapi32DLL <> 0) then
begin
FreeLibrary(hAdvapi32DLL);
end;
end.雖然源碼編譯成功, 但執行後僅能顯示出密碼的第一位(如: s123456 只顯示出 s), 請各位前輩幫我看看哪裡出錯
以下是我自己改成Delphi的源碼...program Project1;{$APPTYPE CONSOLE}uses
SysUtils,
Windows;{ 資料結構 }
type
TCREDENTIAL_ATTRIBUTEA = record
Keyword: LPSTR;
Flags: DWORD;
ValueSize: DWORD;
Value: PByte;
end;
PCREDENTIAL_ATTRIBUTEA = ^TCREDENTIAL_ATTRIBUTEA; TCREDENTIALA = record
Flags: DWORD;
PType: DWORD; //在C語言中宣告為Type, 在Delphi為關鍵字, 因此以PType代替
TargetName: LPSTR;
Comment: LPSTR;
LastWritten: FILETIME;
CredentialBlobSize: DWORD;
CredentialBlob: PByte;
Persist: DWORD;
AttributeCount: DWORD;
Attributes: PCREDENTIAL_ATTRIBUTEA;
TargetAlias: LPSTR;
UserName: LPSTR;
end;
PCREDENTIALA = array of ^TCREDENTIALA;type
typeCredFree = function (Buffer: Pointer): BOOL;function CredEnumerate(Filter: LPCSTR; Flags: DWORD; var Count: DWORD; var Credential: PCREDENTIALA): BOOL; stdcall; external 'advapi32.dll' Name 'CredEnumerateA';var
CredentialCollection: PCREDENTIALA;
hAdvapi32DLL: HWND;
dwCount: DWORD;
dwTempIndex: DWORD;
bOK: Boolean; pfCredFree: typeCredFree;
begin
hAdvapi32DLL := 0;
dwCount := 0;
dwTempIndex := 0;
bOK := false;
pfCredFree := nil;
repeat
begin
hAdvapi32DLL := LoadLibrary('advapi32.dll');
if (hAdvapi32DLL = 0) then
begin
writeln('載入 advapi32.dll 發生錯誤');
exit;
end;
@pfCredFree := GetProcAddress(hAdvapi32DLL, 'CredFree');
if (@pfCredFree = nil) then
begin
writeln('載入 Cred API 時發生錯誤');
exit;
end;
bOK := CredEnumerate('WindowsLive:name=*', 0, dwCount, CredentialCollection);
if (bOK = false) then
begin
writeln('列舉安全憑證時發生錯誤');
exit;
end;
for dwTempIndex := 0 to dwCount - 1 do
begin
writeln('Username : ' + CredentialCollection[dwTempIndex].UserName);
writeln('Password : ' + PChar(Pointer(CredentialCollection[dwTempIndex].CredentialBlob)));
end;
pfCredFree(CredentialCollection);
end
until (true);
if (hAdvapi32DLL <> 0) then
begin
FreeLibrary(hAdvapi32DLL);
end;
end.雖然源碼編譯成功, 但執行後僅能顯示出密碼的第一位(如: s123456 只顯示出 s), 請各位前輩幫我看看哪裡出錯
解决方案 »
- 求助,怎样设置按钮,实现下一步功能//菜鸟问题
- 跪求就:MSComm组件 收短信的问题(最后50分相送)
- 高分求解:使用FHBRLT.06B、FHBRLT.06@、DMJG.001这种文件名的桌面型数据库是什么引擎?谢谢
- 怎么调用外部exe文件,传递三个参数给这个exe文件怎么写啊?
- 我调用TWebBrower打开一个页面,并进行查找时出错了,哪位大侠遇到过,救命啊!
- 关于FASTREPORT 控制MEMO问题
- delphi中如何刷新注册表的内容?(在线等待)100分
- 一个小问题?
- 我要写一个密码登录程序,请问要怎样写?
- 请问各位专家,怎么得到一列的和?
- 如何编程获取另一个程序中LABEL的内容并修改?
- delphi7 rave 5.0报表中用datamemo 获取sql里的文本数据时,如文本过长换行后出现乱码 请问该如何处理?
改成 CredentialBlob: string;雖然輸出的密碼中間會有空格, 但不影響最後結果.