?
Solved

Generating PIF files

Posted on 1999-07-07
3
Medium Priority
?
198 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
  • 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

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
This is an update to some code that someone else posted on Experts Exchange. It is an alternate approach, I think a little easier to use, & makes sure that things like the Task Bar will update.
How to fix display issue, screen flickering issue when I plug in power cord to the machine. Before I start explaining the solution lets check out once the issue how it looks like after I connect the power cord. most of you also have faced this…
There may be issues when you are trying to access Outlook or send & receive emails or due to Outlook crash which leads to corrupt or damaged PST file. To eliminate the corruption from your PST file, you need to repair the corrupt Outlook PST file. U…

600 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