网站首页  词典首页

请输入您要查询的函数:

 

术语 getapplicationrestartsettings
释义 GetApplicationRestartSettings
语法:
C++
HRESULT WINAPI GetApplicationRestartSettings(
__in HANDLE hProcess,
__out_opt PWSTR pwzCommandline,
__inout PDWORD pcchSize,
__out_opt PDWORD pdwFlags
);
GetApplicationRestartSettings功能
检索重新启动指定的进程注册信息。
参数
hProcess [in]
句柄的进程。这种处理必须有PROCESS_VM_READ访问权。
pwzCommandline [指出,可选]
阿一个缓冲区,它接收命令行重新启动该应用程序时,它被称为RegisterApplicationRestart函数指定的指针。在命令行的最大规模的字符,是RESTART_MAX_CMD_LINE。可以为NULL,如果pcchSize是零。
pcchSize [ in , out ]
在输入,指定pwzCommandLine以字符缓冲区的大小。
如果缓冲区不够大,无法接受命令行,该函数失败,HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER),并设置此参数所需的缓冲区大小,以字符。
对产出,指定使用的是缓冲区大小。
要确定所需的缓冲区大小,设置pwzCommandLine为NULL,这为0参数。该大小包括对空终止字符之一。请注意该函数返回S_OK,不HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER)在这种情况下。
pdwFlags [指出,可选]
一个变量,它接收由应用程序时,它被称为RegisterApplicationRestart函数指定的国旗指针。
返回值
这个函数返回S_OK在成功或下面的错误代码之一。
返回codeDescription
E_INVALIDARGOne或多个参数无效。
HRESULT_FROM_WIN32(ERROR_NOT_FOUND)申请注册并没有重新启动。
HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER)在pwzCommandLine缓冲区太小。该函数返回pcchSize所需的缓冲区大小。使用所需的大小重新分配缓冲区。
备注
此信息仅适用于目前的进程,您不能调用您的程序后,重新启动该功能得到重新启动命令行。为了重新启动后,进入您的主要职能argv参数的命令行。
实例
下面的示例演示如何获取重新启动时指定称为RegisterApplicationRestart功能设置。
#include
#include

void wmain(int argc, WCHAR* argv[])
{
HRESULT hr = S_OK;
WCHAR wsCommandLine[RESTART_MAX_CMD_LINE + 1];
DWORD cchCmdLine = sizeof(wsCommandLine) / sizeof(WCHAR);
DWORD dwFlags = 0;
LPWSTR pwsCmdLine = NULL;

wprintf(L"Registering for restart...\\n");
hr = RegisterApplicationRestart(L"/restart -f .\\\\filename.ext", 0);
if (FAILED(hr))
{
wprintf(L"RegisterApplicationRestart failed, 0x%x\\n", hr);
goto cleanup;
}
wprintf(L"Get restart command line using static buffer...\\n");
hr = GetApplicationRestartSettings(GetCurrentProcess(), wsCommandLine, &cchCmdLine, &dwFlags);
if (FAILED(hr))
{
wprintf(L"GetApplicationRestartSettings failed, 0x%x\\n", hr);
goto cleanup;
}
wprintf(L"Command line: %s\\n", wsCommandLine);
wprintf(L"\\nGet settings using dynamic buffer...\\n");
cchCmdLine = 0;
// Returns S_OK instead of ERROR_INSUFFICIENT_BUFFER when pBuffer is NULL and size is 0.
hr = GetApplicationRestartSettings(GetCurrentProcess(), (PWSTR)pwsCmdLine, &cchCmdLine, &dwFlags);
if (SUCCEEDED(hr))
{
pwsCmdLine = (LPWSTR)malloc(cchCmdLine * sizeof(WCHAR));
if (pwsCmdLine)
{
hr = GetApplicationRestartSettings(GetCurrentProcess(), (PWSTR)pwsCmdLine, &cchCmdLine, &dwFlags);
if (FAILED(hr))
{
wprintf(L"GetApplicationRestartSettings failed with 0x%x\\n", hr);
goto cleanup;
}
wprintf(L"Command line: %s\\n", pwsCmdLine);
}
else
{
wprintf(L"Allocating the command-line buffer failed.\\n");
}
}
else
{
if (hr != HRESULT_FROM_WIN32(ERROR_NOT_FOUND)) // Not a restart.
{
wprintf(L"GetApplicationRestartSettings failed with 0x%x\\n", hr);
goto cleanup;
}
}
cleanup:
if (pwsCmdLine)
free(pwsCmdLine);
}
要求:
client最低支持Vista
server最低支持 Windows Server 2008
HeaderWinbase.h(头文件:winuser.h)
LibraryKernel32.lib
DLLKernel32.dll
参见
RegisterApplicationRestart
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年7月30日
==英文原文==GetApplicationRestartSettings Function
Retrieves the restart information registered for the specified process.
Syntax
C++
HRESULT WINAPI GetApplicationRestartSettings(
__in HANDLE hProcess,
__out_opt PWSTR pwzCommandline,
__inout PDWORD pcchSize,
__out_opt PDWORD pdwFlags
);
Parameters
hProcess [in]
A handle to the process. This handle must have the PROCESS_VM_READ access right.
pwzCommandline [out, optional]
A pointer to a buffer that receives the restart command line specified by the application when it called the RegisterApplicationRestart function. The maximum size of the command line, in characters, is RESTART_MAX_CMD_LINE. Can be NULL if pcchSize is zero.
pcchSize [in, out]
On input, specifies the size of the pwzCommandLine buffer, in characters.
If the buffer is not large enough to receive the command line, the function fails with HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER) and sets this parameter to the required buffer size, in characters.
On output, specifies the size of the buffer that was used.
To determine the required buffer size, set pwzCommandLine to NULL and this parameter to zero. The size includes one for the null-terminator character. Note that the function returns S_OK, not HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER) in this case.
pdwFlags [out, optional]
A pointer to a variable that receives the flags specified by the application when it called the RegisterApplicationRestart function.
Return Value
This function returns S_OK on success or one of the following error codes.
Return codeDescription
E_INVALIDARGOne or more parameters are not valid.
HRESULT_FROM_WIN32(ERROR_NOT_FOUND)The application did not register for restart.
HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER)The pwzCommandLine buffer is too small. The function returns the required buffer size in pcchSize. Use the required size to reallocate the buffer.

Remarks
This information is available only for the current process; you cannot call this function after your program is restarted to get the restart command line. To get the command line after a restart, access the argv parameter of your main function.
Examples
The following example shows how to get the restart settings specified when you called the RegisterApplicationRestart function.
#include
#include

void wmain(int argc, WCHAR* argv[])
{
HRESULT hr = S_OK;
WCHAR wsCommandLine[RESTART_MAX_CMD_LINE + 1];
DWORD cchCmdLine = sizeof(wsCommandLine) / sizeof(WCHAR);
DWORD dwFlags = 0;
LPWSTR pwsCmdLine = NULL;

wprintf(L"Registering for restart...\\n");
hr = RegisterApplicationRestart(L"/restart -f .\\\\filename.ext", 0);
if (FAILED(hr))
{
wprintf(L"RegisterApplicationRestart failed, 0x%x\\n", hr);
goto cleanup;
}
wprintf(L"Get restart command line using static buffer...\\n");
hr = GetApplicationRestartSettings(GetCurrentProcess(), wsCommandLine, &cchCmdLine, &dwFlags);
if (FAILED(hr))
{
wprintf(L"GetApplicationRestartSettings failed, 0x%x\\n", hr);
goto cleanup;
}
wprintf(L"Command line: %s\\n", wsCommandLine);
wprintf(L"\\nGet settings using dynamic buffer...\\n");
cchCmdLine = 0;
// Returns S_OK instead of ERROR_INSUFFICIENT_BUFFER when pBuffer is NULL and size is 0.
hr = GetApplicationRestartSettings(GetCurrentProcess(), (PWSTR)pwsCmdLine, &cchCmdLine, &dwFlags);
if (SUCCEEDED(hr))
{
pwsCmdLine = (LPWSTR)malloc(cchCmdLine * sizeof(WCHAR));
if (pwsCmdLine)
{
hr = GetApplicationRestartSettings(GetCurrentProcess(), (PWSTR)pwsCmdLine, &cchCmdLine, &dwFlags);
if (FAILED(hr))
{
wprintf(L"GetApplicationRestartSettings failed with 0x%x\\n", hr);
goto cleanup;
}
wprintf(L"Command line: %s\\n", pwsCmdLine);
}
else
{
wprintf(L"Allocating the command-line buffer failed.\\n");
}
}
else
{
if (hr != HRESULT_FROM_WIN32(ERROR_NOT_FOUND)) // Not a restart.
{
wprintf(L"GetApplicationRestartSettings failed with 0x%x\\n", hr);
goto cleanup;
}
}
cleanup:
if (pwsCmdLine)
free(pwsCmdLine);
}
Requirements
Minimum supported clientWindows Vista
Minimum supported serverWindows Server 2008
HeaderWinbase.h (include Windows.h)
LibraryKernel32.lib
DLLKernel32.dll
See Also
RegisterApplicationRestart
Send comments about this topic to Microsoft
Build date: 7/30/2009
==原始网址==http://msdn.microsoft.com/en-us/library/aa373344(VS.85).aspx\n
随便看

 

windows api函数参考手册包含2258条windows api函数文档,详细介绍nodejs、java、rust调用windows api的方法技巧,是学习windows api编程的入门中文文档。

 

Copyright © 2004-2023 Winrtm.com All Rights Reserved
京ICP备2021023879号-40 更新时间:2024/10/6 11:28:19