bpayne111 Posted November 11, 2004 Posted November 11, 2004 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 Quote i'm not lazy i'm just resting before i get tired.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.