Solved

Passing Parameters/values between EXE's

Posted on 2002-04-04
13
206 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
error 1.1 400 Bad request idhttp delphi 18 200
Multiple image collision 13 88
PHP preg_replace code convert to Delphi 14 80
Delphi Seattle StructureView color 1 21
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

763 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