Training
Module
Manage drivers and device peripherals - Training
This module introduces device drivers. Student will learn how drivers work and the tools used to manage common peripheral devices such as printers.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
The Shell API provides functions that you can use to manage networked printers. If a file has the print verb associated with it, you can use the ShellExecuteEx command to print it.
You can manage printers on a system with the SHInvokePrinterCommand function. This function allows you to:
If a file type has a print command associated with it, you can print the file by calling ShellExecuteEx with print as the verb. This command is often the same as that used for the open verb, with the addition of a flag to tell the application to print the file. For instance, .txt files can be printed by Microsoft WordPad. The open verb for a .txt file would thus correspond to something like the following command:
"C:\Program Files\Windows NT\Accessories\Wordpad.exe" /p "%1"
When you use ShellExecuteEx to print a .txt file, WordPad opens the file, prints it, and then closes, returning control to the application. The following sample function takes a fully qualified path, and uses ShellExecuteEx to print it, using the print command associated with its file name extension.
#include <shlobj.h>
HINSTANCE PrintFile(LPCTSTR pszFileName)
{
SHELLEXECUTEINFO ShExecInfo;
HINSTANCE hInst;
// Fill the SHELLEXECUTEINFO array.
ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
ShExecInfo.fMask = NULL;
ShExecInfo.hwnd = NULL;
ShExecInfo.lpVerb = "print";
ShExecInfo.lpFile = pszFileName; // a fully qualified path
ShExecInfo.lpParameters = NULL;
ShExecInfo.lpDirectory = NULL;
ShExecInfo.nShow = SW_MAXIMIZE;
ShExecInfo.hInstApp = NULL;
hInst = ShellExecuteEx(&ShExecInfo);
return hInst;
}
Training
Module
Manage drivers and device peripherals - Training
This module introduces device drivers. Student will learn how drivers work and the tools used to manage common peripheral devices such as printers.