?
Solved

Generating PIF files

Posted on 1999-07-07
3
Medium Priority
?
197 Views
Last Modified: 2010-04-06
In our application we still have a lot of DOS-based applications.  These DOS-apps can be runned one after the other and in that case we have to make sure that for every EXE there's a PIF with the 'Close on exit' checkbox marked, so the DOS-window is closed when the application finishes.
PIF files made under NT don't work under 95/98, so before starting the DOS EXE we'd like to create a PIF file beside it at run time and place the checkbox 'Close on exit' marked.  Can this be done programatically???
0
Comment
Question by:GuntherDS
[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
  • 2
3 Comments
 
LVL 20

Accepted Solution

by:
Madshi earned 390 total points
ID: 1387127
Not with documented APIs. But you can use this one...  :-)

function CreateLink(pathObj, pathLink: string; closeOnExit: boolean) : HRESULT;
var sl : IShellLink;
    s1 : string;
begin
  CoInitialize(nil);
  sl:=CreateComObject(CLSID_ShellLink) as IShellLink;
  sl.SetPath(PChar(pathObj));
  result:=(sl as IPersistFile).Save(PWideChar(wideString(pathLink)),true);
  CoUninitialize;
  with TFileStream.Create(pathLink,fmOpenReadWrite) do
    try
      SetLength(s1,size);
      ReadBuffer(pointer(s1)^,length(s1));
      position:=0;
      if closeOnExit then byte(s1[$64]):=ord(s1[$64]) or       $10
      else                byte(s1[$64]):=ord(s1[$64]) and (not $10);
      WriteBuffer(pointer(s1)^,length(s1));
    finally Free end;
end;

  CreateLink('c:\command.com','c:\test.pif',true);

Regards, Madshi.

P.S: You need D3 or D4 to compile it...
0
 

Author Comment

by:GuntherDS
ID: 1387128
But after looking on MSDN we found a more simple solution, create a _default.pif (with the 'Close on exit' checked) in de windows system directory.  This is the default
0
 
LVL 20

Expert Comment

by:Madshi
ID: 1387129
Yes, but this effects the whole system, not only your app. Don't know if your costumers like that...

Regards, Madshi.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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 I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

719 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