Click here to Skip to main content
16,015,414 members
Home / Discussions / C#
   

C#

 
GeneralSubVersion Question.... Pin
Harvey Saayman25-Apr-08 3:25
Harvey Saayman25-Apr-08 3:25 
Questionhow do I get serial hardware from client with c# or vb.net Pin
indy25-Apr-08 2:46
indy25-Apr-08 2:46 
AnswerRe: how do I get serial hardware from client with c# or vb.net Pin
Spacix One25-Apr-08 3:58
Spacix One25-Apr-08 3:58 
AnswerRe: how do I get serial hardware from client with c# or vb.net Pin
Ravenet25-Apr-08 6:01
Ravenet25-Apr-08 6:01 
GeneralRe: how do I get serial hardware from client with c# or vb.net Pin
indy25-Apr-08 6:47
indy25-Apr-08 6:47 
GeneralRe: how do I get serial hardware from client with c# or vb.net Pin
Ravenet25-Apr-08 21:38
Ravenet25-Apr-08 21:38 
GeneralRe: how do I get serial hardware from client with c# or vb.net Pin
indy25-Apr-08 22:03
indy25-Apr-08 22:03 
QuestionProblem writing to the remote machine registry Pin
sumitchavan25-Apr-08 0:39
sumitchavan25-Apr-08 0:39 
HI all

I am trying to set the registry value on the remote machine. I am able to connect to the remote machine.

But while setting the value i am getting the error of INVALID HANDLE..

Here is the code snippet... Can any one tell exactly where i am getting wrong..



using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;


namespace LastRegTry
{
class Program
{


[DllImport("advapi32")]
static extern int RegConnectRegistry(string machine, UIntPtr hKey, out UIntPtr pRemKey);

[DllImport("advapi32")]
static extern int RegCloseKey(UIntPtr hKey);

[DllImport("advapi32")]
static extern int RegSaveKey(IntPtr hKey, string fileout, IntPtr secdesc);

[DllImport("advapi32")]
static extern int RegOpenKeyEx(UIntPtr hKey, string lpSubKey, int ulOptions , int samDesired, UIntPtr

phkResult);

[DllImport("advapi32")]
static extern int RegSetValueEx(UIntPtr hKey, string lpValueName, int reserved, int dwType, string

lpData, int cbData);

private const int KEY_ALL_ACCESS = 0xF003F;
private const int KEY_READ = 0x20019;
public const int REG_SZ = 1;



static void Main(string[] args)
{


const uint HKEY_CLASSES_ROOT = 0x80000000;
const uint HKEY_CURRENT_USER = 0x80000001;
const uint HKEY_LOCAL_MACHINE = 0x80000002;


UIntPtr key = new UIntPtr(HKEY_LOCAL_MACHINE);
//remKeyUIntPtr hKey = UIntPtr.Zero;
UIntPtr remKey;
int ret = RegConnectRegistry("MYMACHINENAME", key, out remKey);
string appPath = "c:\\sumit";

if (ret == 0)
{
//int r = RegSaveKey(remKey, "c:\\regRootsave", IntPtr.Zero);
int r = RegOpenKeyEx(key, "Software\\Microsoft\\Windows\\CurrentVersion\\RunOnceEx", 0,

KEY_ALL_ACCESS, remKey);
if (r != 0)
Console.WriteLine("Error: {0}", r);

int i = RegSetValueEx(remKey, "sumit", 0, REG_SZ, "vauletoset", appPath.Length);
if (i != 0)
Console.WriteLine("Error: {0}", i);

if (remKey != UIntPtr.Zero)
r = RegCloseKey(remKey);

}

}
}
}


Thanks in advance Smile | :)
GeneralRe: Problem writing to the remote machine registry Pin
Mircea Puiu25-Apr-08 1:37
Mircea Puiu25-Apr-08 1:37 
GeneralRe: Problem writing to the remote machine registry Pin
Vasudevan Deepak Kumar25-Apr-08 2:19
Vasudevan Deepak Kumar25-Apr-08 2:19 
QuestionHow to add system drives icons to tree View Pin
Naveed72725-Apr-08 0:04
Naveed72725-Apr-08 0:04 
AnswerRe: How to add system drives icons to tree View Pin
Spacix One25-Apr-08 4:07
Spacix One25-Apr-08 4:07 
AnswerRe: How to add system drives icons to tree View Pin
Ravenet25-Apr-08 6:04
Ravenet25-Apr-08 6:04 
Questionmy HTTP request handler code correct? Pin
George_George25-Apr-08 0:02
George_George25-Apr-08 0:02 
AnswerRe: my HTTP request handler code correct? Pin
Spacix One25-Apr-08 2:22
Spacix One25-Apr-08 2:22 
GeneralRe: my HTTP request handler code correct? Pin
George_George25-Apr-08 2:50
George_George25-Apr-08 2:50 
GeneralRe: my HTTP request handler code correct? Pin
Spacix One25-Apr-08 3:28
Spacix One25-Apr-08 3:28 
GeneralRe: my HTTP request handler code correct? Pin
George_George25-Apr-08 4:00
George_George25-Apr-08 4:00 
GeneralRe: my HTTP request handler code correct? Pin
Spacix One25-Apr-08 5:34
Spacix One25-Apr-08 5:34 
GeneralRe: my HTTP request handler code correct? Pin
George_George25-Apr-08 21:34
George_George25-Apr-08 21:34 
QuestionHow to Assign value to CodeMemberField object in CodeDom ? Pin
hdv21224-Apr-08 23:30
hdv21224-Apr-08 23:30 
Questionextracting domain name from email.. Pin
Adoremi24-Apr-08 23:13
Adoremi24-Apr-08 23:13 
GeneralRe: extracting domain name from email.. Pin
phannon8624-Apr-08 23:30
professionalphannon8624-Apr-08 23:30 
GeneralRe: extracting domain name from email.. Pin
Giorgi Dalakishvili24-Apr-08 23:37
mentorGiorgi Dalakishvili24-Apr-08 23:37 
AnswerRe: extracting domain name from email.. [modified] Pin
Spacix One25-Apr-08 2:57
Spacix One25-Apr-08 2:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.