您的位置:首页 > 运维架构 > Shell

介绍几个API,SetConsoleTextAttribute / AttachConsole / ShellExecute / _searchenv ...

2005-11-14 23:00 681 查看
彩色命令行:
BOOL SetConsoleTextAttribute(
HANDLE hConsoleOutput,
WORD wAttributes
);

附到console上去:
The AttachConsole function attaches the calling process to the console
of the specified process.
BOOL AttachConsole(
DWORD dwProcessId
);

从Shell中执行文件
效果类似于Console中的start命令以及explorer中的双击事件,shell会自动选择默认的程序来打开:
HINSTANCE ShellExecute(
HWND hwnd,
LPCTSTR lpOperation,
LPCTSTR lpFile,
LPCTSTR lpParameters,
LPCTSTR lpDirectory,
INT nShowCmd
);

配合查找shell path的CRT函数可以模拟 开始->运行
void _searchenv(
const char *filename,
const char *varname,
char *pathname
);
void _wsearchenv(
const wchar_t *filename,
const wchar_t *varname,
wchar_t *pathname
);

快捷方式(恼火啊,偶当时用的可是IShellxxx)
SHCreateShortcut : This function creates a shortcut.
SHCreateShortcutEx : This function automatically creates a uniquely named shortcut in a specified directory.

这里可以搞到更多...
BrowseCallbackProc This function specifies an application-defined callback function used with the SHBrowseForFolder function.
ChooseFont This function creates a Font dialog box that enables the user to choose attributes for a logical font.
SHAddToRecentDocs This function adds a document to the shell's list of recently used documents or clears all documents from the list.
SHBrowseForFolder This function displays a dialog box that allows a user to select a folder.
SHCreateShortcut This function creates a shortcut.
SHCreateShortcutEx This function automatically creates a uniquely named shortcut in a specified directory.
Shell_NotifyIcon This function sends a message to the system to add, modify, or delete an icon from the taskbar status area.
ShellExecuteEx This function performs an action on a file. The file can be an executable file or a document.
SHFileOperation This function can be used to copy, move, rename, or delete a file system object.
SHGetDesktopFolder Retrieves the IShellFolder interface for the desktop folder, which is the root of the shell's namespace.
SHGetDocumentsFolder This function retrieves the path to the documents directory for the volume specified in the pszVolume parameter.
SHGetFileInfo This function retrieves information about an object in the file system, such as a file, a folder, a directory, or a drive root.
SHGetMalloc This function retrieves a pointer to the shell's IMalloc interface.
SHGetPathFromIDList This function converts an item identifier list to a file system path.
SHGetShortcutTarget This function retrieves the shortcut's target path.
SHGetSpecialFolderLocation This function retrieves the location of a special folder, such as My Handheld PC, Recycle Bin, Desktop, Printers, Fonts, or various file system directories.
SHGetSpecialFolderPath This function retrieves the path of a special folder, identified by its CSIDL.
SHLoadDIBitmap This function loads a bitmap from the specified file.
SHShowOutOfMemory This function displays a system-defined dialog box notifying the user that memory is full.
StrRetToBuf This function takes a STRRET structure returned by IShellFolder::GetDisplayNameOf, converts it to a string, and places the result in a buffer.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: