Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Passing Parameters/values between EXE's

Posted on 2002-04-04
13
Medium Priority
?
210 Views
Last Modified: 2010-04-04
Hi,

I am wanting to create an application(s) where a LOGIN DIALOG appears and asks the User for their ID and Password.

This Dialog will then check if a valid user, and run the Main Application.

I want the Main Application to run ONLY if it receives an ok from the Login Dialog Box. Therefore, the main Application cannot run without running the Login Dialog first.

Could someone please help, sample code would be greatly appreciated.

Thanks
pje
0
Comment
Question by:pjelias
  • 3
  • 3
  • 2
  • +4
13 Comments
 
LVL 11

Expert Comment

by:robert_marquardt
ID: 6920095
This has an inherent problem. As long as you only pass the "OK/Fail" informaiton it is easily hackable.

The easiest way is to implement a command line parameter.

Now tell why you want a separate login dialog application instead of integrating it into your app.
0
 

Author Comment

by:pjelias
ID: 6920174
The Initial EXE (Login Dialog) may be used to check if the Main Application has an updated version of the EXE available, if so copy that down to the Users PC, and then Run the MAIN application from the users PC.

The System would be used by Internal staff Only, and I doubt that people would try to hack into the system.

Also, other information may be passed apart from OK/Fail, which may be encrypted.
0
 
LVL 11

Expert Comment

by:robert_marquardt
ID: 6920187
So commandline is the easiest way.
You can try to add binary data as commandline parameter.
That should prevent easy hacks (even if you think nobody will hack).
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:pjelias
ID: 6920214
can you give an example for code to SEND, and Code to RECEIVE.

That is How do I send the info from the LOGON Dialog, and then How do I Get that Info in the MAIN Application.
0
 
LVL 12

Expert Comment

by:Lee_Nover
ID: 6920451
to launch the app with params you do:
ShellExecute(0, nil, PChar(MainApplicationFileName), PChar(someparameteres), nil, SW_SHOW);

in the main app in the project file or on the mainforms OnCreate event .. do:
if ParamCount > 0 then begin
  if ParamStr(1) = 'ok' then
    DoStuff
  else
    Apllication.Terminate;
end;

ParamStr is 1-based if you look from the parameters
ParamStr(0) returns the application filename
0
 

Expert Comment

by:mathought
ID: 6923059
Two processes can communicate through the means of Named-Pipes.
CreateNamedPipe(), ConnectNamedPipe(), DisconnectNamedPipe(), ...
0
 
LVL 1

Expert Comment

by:OryxConLara
ID: 6923542
pjelias--

We do exactly the same thing here, but this is with a commercial app. You could pass the current datetime as a float in the parameter, which wouldn't be an obvious thing to someone surrptitiously trying to run the main app directly. Leave some flexibility to allow for system delays.

Following on Lee's code,

LOGIN.EXE:
var sdt :string;
sdt := format('13.6f',[Now]);
ShellExecute(0, nil, PChar(MainApplicationFileName), PChar(sdt), nil, SW_SHOW);

MAIN.EXE
OnCreate event .. do:

var
  dt :double;
  code :integer;
if ParamCount > 0 then
begin
  val(ParamStr(1),dt,code);
  if    (code = 0)
    AND (Now-dt <= 4/(24*60*60))  // max 4 seconds leeway
     then
   DoStuff
 else
   Application.Terminate
end;

0
 
LVL 3

Expert Comment

by:SteveWaite
ID: 6924396
This is what you do:

Sending app:

var
  MessageString: String;
  MessageAtom: TAtom;
  Buffer: array[0..255] of Char;

//in create
WmMyStringData := RegisterWindowMessage(‘MyStringData’);
//..

//send message
MessageString :=  ‘a load of string data’;
MessageAtom := GlobalAddAtom(StrPcopy(Buffer, MessageString));
SendMessage(HWnd_Broadcast, WmMyStringData, 0, MessageAtom);
GlobalDeleteAtom(MessageAtom);


Receiving app:

//in create
WmMyStringData := RegisterWindowMessage(‘MyStringData’);

//TForm1
public
    { Public declarations }
procedure DefaultHandler(var Message); override;

procedure TForm1.DefaultHandler(var Message);
var
  Buffer: array [0..255] of Char;
  MessageString: String;
begin
  inherited DefaultHandler(Message);
  with TMessage(Message) do
  begin
    if  Msg = WmMyStringData then
      if not (GlobalGetAtomName(lParam, Buffer, 255) = 0)
        then MessageString := StrPas(Buffer);
    // if ..
  end;
end;
0
 

Author Comment

by:pjelias
ID: 7109828
Decided against in the end.

Other security measures used.
0
 

Expert Comment

by:modulo
ID: 7836798
Dear expert(s),

A request has been made to close this Q in CS:
http://www.experts-exchange.com/Community_Support/CleanUp/Q_20486853.html

Without a response in 72 hrs, a moderator will finalize this question by:

- Saving this Q as a PAQ and refunding the points to the questionner

When you agree or disagree, please add a comment here.

Thank you.

modulo

Community Support Moderator
Experts Exchange
0
 
LVL 11

Expert Comment

by:robert_marquardt
ID: 7836933
agreed
0
 
LVL 12

Expert Comment

by:Lee_Nover
ID: 7837108
agreed
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 7859173
Saving this Q as a PAQ and refunding the points to the questionner

Thanks robert_marquardt and Lee_Nover !

modulo

Community Support Moderator
Experts Exchange
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question