Hi -
I assume that you are a C# programmer, and want some code to do this. As far as I know, there is no easy programming API to find out this information - it isn't the Win32 API, but rather the Windows internal API. However, the SysInternals suite of command line utilities (http://technet.microsoft.com/en-us/sysinternals/bb842062.aspx) can be used to find out this information.
The application you want is called Handle.
There will be no differences to the OS between what you call "internal files" (presumably ones opened by the program without user involvement) and ones which the user deliberately used. You will have to supply this information by specifying the extension of the file. For instance, if you wanted to find all the word files open in Word, the command line you would need is:
handle -p winword.exe | find ".doc"
If writing an app in C#, you could use the following class to return a list of open documents which match your pattern (note this contains a form called ShowOpenAppFilesForm, with two text boxes appExeNameTextBox and fileExtensionTextBox, and a list box openFileListBox):
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Text;
using System.Windows.Forms;
namespace ShowOpenAppFiles
{
public partial class ShowOpenAppFilesForm : Form
{
private const string HandlePath = @"D:\Development\SysInternals\SysinternalsSuite\Handle.exe";
public ShowOpenAppFilesForm()
{
InitializeComponent();
}
private void showButton_Click(object sender, EventArgs e)
{
string[] fileExtensions = new string[1];
fileExtensions[0] = fileExtensionTextBox.Text;
openFileListBox.DataSource = Show(appExeNameTextBox.Text, fileExtensions);
}
private List<string> Show(string programExeName, string[] fileExtensions)
{
Process childProcess = new Process();
ProcessStartInfo startInfo = childProcess.StartInfo;
startInfo.FileName = HandlePath;
startInfo.Arguments = " -p " + programExeName;
startInfo.CreateNoWindow =false;
startInfo.ErrorDialog = false;
startInfo.RedirectStandardOutput = true;
startInfo.UseShellExecute = false;
childProcess.Start();
StreamReader stdOutput = childProcess.StandardOutput;
List<string> fileNameList = new List<string>();
while (!stdOutput.EndOfStream)
{
string line = stdOutput.ReadLine();
for (int i = 0; i < fileExtensions.Length; i++)
{
if (line.Contains("." + fileExtensions[i]))
{
fileNameList.Add(line.Substring(21));
}
}
}
childProcess.WaitForExit();
return fileNameList;
}
}
}
[Incidentally, DDE is mostly toast now.]