The function WriteMAC (model: integer) : integer;
Var
Reg: TRegistry;
The begin
Reg:=TRegistry. Create;//create the registry objects
Reg. RootKey:=HKEY_LOCAL_MACHINE;//specify the registry in registry key HKLM
root forIf reg. OpenKey (' \ System \ CurrentControlSet \ Control \ Class \
{4 d36e972 - E325 ce - BFC1-08002-11 be10318} \ '0013, true) then
The begin//if the item is
Reg. WriteString (' NetworkAddress ', '000 b6ac824c4');//to write MAC value into the NetworkAddress keys
Winexec (' devcon DEV_1031 disable * * ', 0).//disable local connection
Sleep (3000);//pause 3 seconds
Winexec (' DEV_1031 devcon enable * *, 0).//to enable effective local connection in order to make the new MAC
Reg. CloseKey;//close the keys
Reg. Free;//release the registry objects
Result:=1;//modify successfully returns 1
End
The else//if there is no return 0
Result:=0;
end;
CodePudding user response:
The registry, directly to find examples of vcSleep is all some
Winexec is an external program execution
CodePudding user response:
Use the API to remove TRegistry, then see TRegistry OpenKey WriteString, CloseKey how make of, copy the lineRegOpenKeyEx
RegCreateKeyEx
RegSetValueEx
RegFlushKey
RegCloseKey
CodePudding user response:
In c + + BUILDER, basic direct copyCodePudding user response:
With c + + builder method, is to use the VCL, basic copy
# include & lt; Registry. Hpp>
Int WriteMAC (int model)
{
TRegistry * reg=new TRegistry ();
Reg - & gt; RootKey=HKEY_LOCAL_MACHINE;
If (reg - & gt; OpenKey (" \ System \ CurrentControlSet \ Control/Class/
{4 d36e972 - E325 ce - BFC1-08002-11 be10318} \ 0013 ", True))
{
Reg - & gt; WriteString (" NetworkAddress ", "000 b6ac824c4");
WinExec (" devcon DEV_1031 disable * * ", 0).
Sleep (3000);
Reg - & gt; CloseKey ();
The delete reg.
return 1;
}
The else return 0;
}
Use the SDK is direct manipulation API
http://www.cnblogs.com/kzloser/archive/2012/11/07/2758404.html
CodePudding user response:
# include & lt; Registry. Hpp>
Int WriteMAC (int model)
{
TRegistry * reg=new TRegistry ();
Reg - & gt; RootKey=HKEY_LOCAL_MACHINE;
If (reg - & gt; OpenKey (" \ System \ CurrentControlSet \ Control/Class/
{4 d36e972 - E325 ce - BFC1-08002-11 be10318} \ 0013 ", True))
{
Reg - & gt; WriteString (" NetworkAddress ", "000 b6ac824c4");
WinExec (" devcon DEV_1031 disable * * ", 0).
Sleep (3000);
Reg - & gt; CloseKey ();
The delete reg.
return 1;
}
//the following change
The delete reg.
return 0;
}
CodePudding user response:
4 floor