Solved

How can i create a application that can only run from a dll

Posted on 2002-03-19
8
126 Views
Last Modified: 2010-04-05
Hello i created a program called Phonebook.exe
i only want to be able to execute it from within a DLL

Does anyone know what code to put in the PhoneBook.exe
so it cannot be double clicked on to open..
thankyou kindly
0
Comment
Question by:Dinkleburger
  • 4
  • 3
8 Comments
 
LVL 11

Accepted Solution

by:
robert_marquardt earned 20 total points
Comment Utility
The easiest trick is to have a secret command line parameter. Only the DLL knows it.
If the commandline parameter is missing in Phonebook.exe then it simply quits without doing anything.
Place the code to check the param in the .dpr
0
 
LVL 6

Expert Comment

by:Stuart_Johnson
Comment Utility
Robert's suggestion is the way I'd do it too.

if ParamCount = 0 then
  Halt;

As he said, do it in the DPR so that none of your forms are made visible first.

Stu.
0
 

Author Comment

by:Dinkleburger
Comment Utility

Thanks
But i am not understanding this

Can my Dll read inside the exe?

or is the Exe reading inside the Dll?

All my Dll is doing is Executing the Phonebook.exe

the same if it is Double clicked on

now i am lost... maybe some sample code for the exe and what i must put in the dll if anything

Thanks in advance
0
 
LVL 6

Expert Comment

by:Stuart_Johnson
Comment Utility
If you double clicked the exe from Explorer, because you're not providing any parameters to the exe, it will close.

When you execute the PHONEBOOK.EXE from your DLL, you do it like this:

ShellExecute(hInstance, 'OPEN', 'PHONEBOOK.EXE,'','/WHATEVER', SW_SHOW);

The /WHATEVER is a dummy parameter that's passed to the EXE.  So, when ShellExecute starts the EXE, it actually runs:

PHONEBOOK.EXE /WHATEVER

Because a parameter is passed, the exe runs perfectly.

Hope this helps,

Stu
0
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.

 

Author Comment

by:Dinkleburger
Comment Utility
Yes Thankyou now i am understanding better
thank you all very very much
0
 

Author Comment

by:Dinkleburger
Comment Utility
Ps Guys i only have the

Accept Comment As Answer Button next to my own Name and Roberts
there is no Button next to your Name Stuart so i want to Accept your answer

I will check back after and see if it is working..

0
 
LVL 6

Expert Comment

by:Stuart_Johnson
Comment Utility
Hi Dinkleburger,

As Robert was the person who suggested the way to do this, it's only fair that he recieves the points.  All I was doing was helping you implement it (something Robert would have no doubtly done if I hadn't jumped in an made a noise).

Cheers all!

Stu

0
 

Author Comment

by:Dinkleburger
Comment Utility
Just one more thing

ShellExecute(hInstance, 'OPEN', 'PHONEBOOK.EXE,",'/WHATEVER', SW_SHOW);

Where the WHATEVER is

i keep getting undeclared identifier

any ideas??
thanks
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now