Solved

Passing Parameters/values between EXE's

Posted on 2002-04-04
13
208 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
[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

 

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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses
Course of the Month7 days, 19 hours left to enroll

617 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