Discussion forum for all Windows batch related topics.
Moderator: DosItHelp
-
dofele
- Posts: 1
- Joined: 22 Oct 2013 08:12
#1
Post
by dofele » 22 Oct 2013 08:16
Hi,
i need to know how i can pass the reference to a variable.
i got an dll which writes the response to a parameter.
example:
Code: Select all
var response=""
rundll32.exe my.dll writeTestToParameter response
echho %response%
the method writeTestToParameter writes "test" to the parameter
so the output should be test.
my problem is that i dont know how to pass the reference of a variable as a parameter.
when i do it like that, the rundll32.exe crashes always.
When i use other programming languages it works, so i think the dll is fine.
thx in advance,
-
penpen
- Expert
- Posts: 2009
- Joined: 23 Jun 2013 06:15
- Location: Germany
#2
Post
by penpen » 22 Oct 2013 15:31
dofele wrote:i need to know how i can pass the reference to a variable.
If you mean "reference" as a C term, then batch scripting doesn't support all types of pointers.
The way variables are used by batches is a hashmap lookup with a key value pair.
The key is the variable name and the value is the variable content.
If you want a memory adress, you have to load the variable in the Memory using your programming language.
penpen
Edit: corrected: ... and the value is the variable name.
Last edited by
penpen on 23 Oct 2013 12:13, edited 1 time in total.
-
aGerman
- Expert
- Posts: 4743
- Joined: 22 Jan 2010 18:01
- Location: Germany
#3
Post
by aGerman » 22 Oct 2013 16:50
An environment variable is the only variable type that is supported in Batch. Environment variables are inherited from the parent process, you can change them for the current process and they are automatically passed on a child process. Any modification of the environment in a child process does never influence the parent environment.
If you want to change the current environment of a Batch process from a child process you have to apply DLL-Injection to run a foreign function as a thread function in the calling cmd.exe process. Of course you can't do that via Batch. Such a feature has to be implemented into the program that was called.
Evaluation of the returned integer (in Batch known as errorlevel) or the parsing of the stdout stream in a FOR /F loop is the usual manner to receive informations from a child process.
Regards
aGerman