Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I�m using c# to write the app but if you know vb.net that will be just fine. Most of my books are in vb.net anyway so I�ve gotten used to translating it. All of my code will be in c#.net unfortunately if that is the case. You can go here to convert c# to vb.net if you need/wish.

This project initially was intended to aid us in establishing internet connections automatically at the stores for updates but, now I am just curious to learn the concept I am missing

 

In my vpn adobe manual there is a very detailed description of the command switches that the client accepts. Two of the parameters (-h and �m); allow a programmer to supply a window handle and a message handle of his program to the vpn client. With these values the vpn will return a true value to the lParam of the message handle I supplied from my program.

 

Some of my trouble comes from not fully understanding how message handles work. I have some groundwork on window handles but next to none on message handles. I�ve looked for documentation explaining the concept better but apparently have been searching for the wrong keywords.

 

I hope all of that made since.

 

Here is the code I wrote

//Objective: to connect the vpn client and confirm a connection has been made using a message handle

//connects vpn 
	private void button2_Click(object sender, System.EventArgs e)
	{
		Message m = new Message();
		vpn.Connect(this.Handle, this.WndProc(m()));

	if(m.LParam==true)
		MessageBox.Show("true");

//code inside the vpn object
public static void Connect(IntPtr windowHandle, IntPtr msgHandle)
	{
		
		try
		{
			//run VPN Client and log in
			System.Diagnostics.ProcessStartInfo ps = new System.Diagnostics.ProcessStartInfo();
			ps.FileName="c:\\program files\\vpn.exe";
			ps.Arguments="-h " + windowHandle.ToInt32().ToString() + " -m " + msgHandle.ToInt32().ToString() + " -s -u user,pw,12.345.678.90";
			System.Diagnostics.Process p = new System.Diagnostics.Process();
			ps.UseShellExecute=false;
			ps.CreateNoWindow = true; 
			p.StartInfo=ps;
			p.Start();
			
		}
		catch
		{ 
		 

		}
	}

First I�m not sure if I�m using the message handle object in the right way. Is there another way to do pass a message handle of my program to the Connect method?

 

In the button2.click event you will see that I used an �if� statement to test for the value of the lParam. I am sure this is not the correct way to do so but throwing that inside an infinite loop doesn�t seem right at all. I�ve considered a sleeping thread but that seems like it wouldn�t be the proper way to do either. I�m almost positive these message handles work in some manner that would fire an event or something. There is a big chunk of the concept of these that I�m misisng

 

I could check the ip address of the vpn network adapter from the registry but I wouldn�t learn anything from that so I gave it a thumbs down.

 

I think (hope) that sums it all up pretty good.

 

Any help?

Brandon

i'm not lazy i'm just resting before i get tired.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...