Solved

Passing Parameters/values between EXE's

Posted on 2002-04-04
13
207 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

751 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