Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Call VFP EXE and return value
Message
From
31/07/2020 22:01:13
 
General information
Forum:
C#
Category:
Coding, syntax and commands
Miscellaneous
Thread ID:
01675453
Message ID:
01675460
Views:
68
>I saw this thread many times. None of the suggestions in the thread work. I tried them all.
>

string userName = System.Security.Principal.WindowsIdentity.GetCurrent().Name;

This gave me computer name/username.

In 2020 we can't be sure of anything, but the result was my computer name and user name, the last time I looked.



>>UPDATE: within 30 seconds Googling [stackoverflow get windows user name c#] I found https://stackoverflow.com/questions/1240373/how-do-i-get-the-current-username-in-net-using-c
>>
>>>I read tons of threads in the stackoverflow and nobody has a clear answer, or just the answer, to how to get a user name in the C# code. VFP does it very simply. So, VFP is much better than C#. The only thing I like in C# is a compiler which checks the syntax and if a variable is used and how. Otherwise, VFP is better.
>>>
>>>I did think about writing the value in a txt file and then reading it from the C# code. But then I have to make sure that each txt file has a unique name (so that there is no conflict). And then delete the txt file.
>>>There has to be a way to return a value from a VFP exe. But if there is none, then writing to a txt file will be the approach.
>>>Thank you.
>>>
>>>>There's got to be a way to do this cleanly within C#, without needing to resort to this VFP kludge. I don't know the answer but it can't be that hard.
>>>>
>>>>If you really want to be enabled for this bad idea, you could write the value to a file with STRTOFILE() and then read it from C#.
>>>>
>>>>>Hi,
>>>>>
>>>>>I need to call a small VFP .EXE from a C#/.NET code. The VFP project has one .PRG with has just one line:
>>>>>
>>>>>RETURN (GetEnv("UserName")) 
>>>>>
>>>>>
>>>>>How do I call this .EXE from C# code?
>>>>>
>>>>>I called VFP EXE in my C# code before using the Proc syntax. Example:
>>>>>
>>>>>Process Proc = Process.Start(cVfpExeFullPath, "1");
>>>>>
>>>>>
>>>>>But before my VFP EXE didn't have to return anything. So, it was simple.
>>>>>
>>>>>Now I want the VFP EXE to return a value and capture this value in the C# code.
>>>>>
>>>>>How?
>>>>>
>>>>>TIA
Anyone who does not go overboard- deserves to.
Malcolm Forbes, Sr.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform