记得很久以前在黑基上看过的了,就修改注册表一个键值而已。
前几天翻了下旧文章,才想起有这个方法。呵呵,把它做成个小程序吧,免得老忘了。
program Open3389;
{$APPTYPE CONSOLE}
uses
SysUtils, Registry, Windows;
var
reg:TRegistry;
procedure Help;
begin
writeln('');
writeln('======Win XP&2003 Open3389 by lanyu====== ');
Writeln('Usage '+ExtractFileName(Paramstr(0))+' [/n]');
end;
begin
{ TODO -oUser -cConsole Main : Insert code here }
if ParamCount>2 then
begin
help;
exit;
end;
reg:=TRegistry.Create;
reg.RootKey:=HKEY_LOCAL_MACHINE;
reg.OpenKey('SYSTEM/CurrentControlSet/Control/Terminal Server',true);
if ParamCount=1 then
begin
if Paramstr(1)='/n' then
begin
try
reg.WriteBool('fDenyTSConnections',true);
Writeln('Close 3389 successfully');
except
Writeln('Close 3389 fail');
end;
end
else
begin
Help;
Exit;
end;
end
else
begin
try
reg.WriteBool('fDenyTSConnections',false);
writeln('Open 3389 successfully');
except
writeln('Open 3389 fail');
end;
end;
reg.Free;
end.