1. Get the full name of the current Windows user (if the domain user contains the domain name, if the local user contains the computer name), the inno implementation code:
Declare the enumeration type EXTENDED_NAME_FORMAT = (NameUnknown, NameFullyQualifiedDN, NameSamCompatible, NameDisplay );
Declare the API method function GetUserNameEx (NameFormat: EXTENDED_NAME_FORMAT; lpNameBuffer: String; var lpnSize: integer): integer;
External 'getusernameexa @ secur32.dll stdcall ';
Implementation Method: function GetUserName (): string;
Var
Ret: integer;
Begin
LpNameBuffer: = '000000 ';
LpNameBuffer: = lpNameBuffer + lpNameBuffer;
Ret: = Length (lpNameBuffer );
NameFormat: = NameSamCompatible;
If getusernameex (nameformat, lpnamebuffer, RET) <> 0 then
Begin
If lpnamebuffer [RET] = #0 then
Begin
RET: = ret-1;
End
Result: = copy (lpnamebuffer, 1, RET );
End
Else
Begin
Result: = '-1 ';
End
End;
There are two major problems in this implementation method:
First, you must initialize a string with sufficient length; otherwise, getusernameex cannot be written;
The second is that the username returned in WINXP system will have a "\ 0" character more than that returned in other systems.
2. In the WinXP system, you must use the computer name to connect to the local SQLServer2005 using OLEDB, but the local or localhost cannot be connected. This problem does not occur when ado.net is used and Express is connected.
3.change the executable file to setup.exe under the vistasystem and it will automatically run as an administrator.