Показать сообщение отдельно
Старый 28.05.2015, 14:12   #1  
Blog bot is offline
Blog bot
Участник
 
25,644 / 848 (80) +++++++
Регистрация: 28.10.2006
palleagermark: Open and close PDF reader from code
Источник: http://www.agermark.com/2015/05/open...from-code.html
==============

Here is an example of how you can open Adobe PDF Reader (or another PDF reader) with a particular PDF document, and close the reader again.
static void pager_FindWindow(Args _args)
{
Filename pdfFileName = 'MyDocumentFile.pdf';
FilePath pdfFilePath = @'C:\XYZ\';
str adobeExe;

System.Diagnostics.Process process;
System.Diagnostics.ProcessStartInfo processStartInfo;

// Let Windows figure out the standard program and location for the PDF reader
adobeExe = WinAPI::findExecutable(pdfFilePath + pdfFileName);

// Start the reader process
new InteropPermission(InteropKind::ClrInterop).assert();

process = new System.Diagnostics.Process();

processStartInfo = new System.Diagnostics.ProcessStartInfo();
processStartInfo.set_FileName(adobeExe);
processStartInfo.set_Arguments(pdfFilePath + pdfFileName);

process.set_StartInfo(processStartInfo);

process.Start();


// Wait 5 secs. before closing the window
sleep (5000);

// Close the window
process.Kill();
}

Источник: http://www.agermark.com/2015/05/open...from-code.html
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.