Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to pass value of variables from one project to another project


i have 1 exe and i have to pass user name to another project (exe)
how can i do
Posted
Updated 21-May-13 2:11am
v2
Comments
ZurdoDev 21-May-13 8:08am    
Good question. Can the other exe accept them?
[no name] 21-May-13 8:10am    
Research Inter Process Communication (IPC).

There is no such thing as "project" during runtime. There are two applications, running separate processes. The processes are well isolated, executed in different address spaces. They cannot communicate unless they are designed for that. In most cases, solving one application problem in two different processes is a bad idea, you should rather have one process and threading. Think about using one of existing project as a class library referenced by another project, if you don't want to merge them.

Everything else depends on your detail. I just can add that if you still have two different processes, they should be specially designed to communication, which is called IPC. It can be communication via named pipes, shared memory, sockets, TcpListener/TcpClient, .NET remoting, WCF… I don't want to go into further detail, as the question was too vague.

But first of all, think about having one application in one process. That's all, based on your limited information.

—SA
 
Share this answer
 
Hello,
I am not sure what you are asking for but the way I pass share settings across my other applications is to use the registry.

As far as I am aware you do not need Administrator permissions to do this.

The code to save a variable to the registry is:

VB
SaveSetting("MyApp", "Startup", "Top", "75") ' Save the variable


In this case the variable's name is "Top" And the value is "75"
It is stored in the following registry location:
[HKEY_CURRENT_USER\Software\VB and VBA Program Settings\MyApp\Startup]



And the code to read the variable in your other application is:

VB
Messagebox.show("Your variable is: " & GetSetting("MyApp", "Startup", "Top", "") ' Read the variable



The added bones is that this will save your variable and is still usable even after the User restarts there computer.


Additional notes:
You may want to conceder using some kind of encryption when storing raw text on a User's computer.


For more information please visit:
http://msdn.microsoft.com/en-us/library/13zyfez5(v=vs.90).aspx?appId=Dev10IDEF1&l=EN-US&k=k(MICROSOFT.VISUALBASIC.INTERACTION.GETSETTING)%3bk(TargetFrameworkMoniker-".NETFRAMEWORK,VERSION%3dV3.5")%3bk(DevLang-VB)&rd=true&cs-save-lang=1&cs-lang=vb#code-snippet-1[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900