主要代碼如下:
private void button
{
tabControl
ThreadStart threadDelegate = new ThreadStart(this
Thread newThread = new Thread(threadDelegate);
newThread
}
private int number =
private void doIt()
{
int maxthread = int
string remoteName;
progressBar
progressBar
for(Decimal i = n_ip
{
remoteName = txt_ipStart
WaitCallback async = new WaitCallback(RunGet);
while(true)
{
Monitor
if(number>
Thread
else
break;
Monitor
}
if(ThreadPool
Interlocked
//RunGet(remoteName);
}
while(true)
{
//myResetEvent
Monitor
if( number <=
break;
else
Thread
Monitor
}
MessageBox
}
private void RunGet(object ip)
{
try
{
RegistryKey environmentKey = null;
string remoteName = ip
try
{
// Open HKEY_CURRENT_USER\Environment
// on a remote computer
environmentKey = RegistryKey
RegistryHive
txt_key
}
catch(IOException ex)
{
addMsg(string
}
// Print the values
// MessageBox
// environmentKey
// environmentKey
//addMsg(environmentKey
object result = environmentKey
if(result != null)
{
addMsg(string
addSuccessMsg(remoteName
}
else
{
addMsg(string
}
// foreach(string valueName in environmentKey
// {
// addMsg(string
// }
// Close the registry key
environmentKey
}
catch
{
}
progressBar
Interlocked
}
private void addMsg(string msg)
{
lb_msg
}
private void addSuccessMsg(string Ip
{
txt_result
}
private void button
{
lb_msg
}
private void button
{
System
sw
sw
MessageBox
}
From:http://tw.wingwit.com/Article/os/xtgl/201311/8971.html