Z
zhgnet
Unregistered / Unconfirmed
GUEST, unregistred user!
我写了个小程序,窗体上只有2个edit对话框,一个按钮,一个label,按钮的click事件如下
procedure TForm1.Button1Click(Sender: TObject);
var
userid,userpwd: string;
hk: hkey;
profile: DWORD;
dwsize,dwtype: DWORD;
r: DWORD;
ul: cardinal;
path: string;
begin
// 获取profile文件
dwtype := REG_SZ;
dwsize := 20;
path := 'Software/Microsoft/Windows NT/CurrentVersion'
+ '/Windows Messaging Subsystem/Profiles';
r := RegOpenKeyEx( HKEY_CURRENT_USER,pchar(path),0,KEY_READ,hk );
if r <> ERROR_SUCCESS then exit;
RegQueryValueEx( hk,'DefaultProfile',nil,@dwtype,PBYTE(profile),@dwsize);
RegCloseKey( hk );
userid := edit1.Text;
userpwd := edit2.Text;
if lsession <> 0 then exit;
if trim( userid ) <> '' then
ul := MAPILogOn( 0,pchar(userid),pchar(userpwd),
MAPI_LOGON_UI OR MAPI_NEW_SESSION,0,@lsession)
else
ul := MAPILogOn( 0,pchar(profile),nil,MAPI_NEW_SESSION,0,@lsession );
if ul <> SUCCESS_SUCCESS then lsession := 0
else
label1.Caption := 'logon success!';
end;
我单步调试时,最后就将程序关闭了,不知为什么,那位大侠遇到过这种问题阿