Solved

Passing Parameters/values between EXE's

Posted on 2002-04-04
13
201 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
 

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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

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…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
This video discusses moving either the default database or any database to a new volume.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now