Solved

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

Posted on 2002-03-19
8
128 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
ID: 6880091
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
ID: 6881671
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
ID: 6881715

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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 6

Expert Comment

by:Stuart_Johnson
ID: 6881729
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
 

Author Comment

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

Author Comment

by:Dinkleburger
ID: 6881836
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
ID: 6884349
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
ID: 6890435
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

821 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