以下的代码为什么会出错?结贴率100%,但被删率25%,我的帖子有点风险的-:)

tiantianpb 2002-08-10 04:36:50
实例变量:
ulong ewx_shutdown=1
局部外部函数引用
public function ulong exitwindowsex(ulong uflags,ulong dwreserved) library "user32.dll"
相关代码:
exitwindowsex(ewx_shutdown,0)
错误信息:
error call external function exitwindowsex .......
...全文
70 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
myclife 2002-08-10
  • 打赏
  • 举报
回复
:')
tiantianpb 2002-08-10
  • 打赏
  • 举报
回复
哈哈哈,还是我的必祥弟弟厉害,给分了,哎!老了,连这个都忘了
ldk 2002-08-10
  • 打赏
  • 举报
回复
我就是这样用的,用来关闭计算机,一切正常呀!
myclife 2002-08-10
  • 打赏
  • 举报
回复
To:tiantianpb(阿九)
不是跟你说了吗,API区分大小写的:)
xhwly 2002-08-10
  • 打赏
  • 举报
回复
FUNCTION boolean ExitWindowsEx(uint uFlags,uint dwReserved) LIBRARY "user32.dll"
tiantianpb 2002-08-10
  • 打赏
  • 举报
回复
to;liulee,这个我知道,要区分操作系统的,但在98下都报错的
bys_home 2002-08-10
  • 打赏
  • 举报
回复
你的错误代码是否不全??
不是很明白
liulee 2002-08-10
  • 打赏
  • 举报
回复
附 AdjustTokenPrivileges 函数参考:

The AdjustTokenPrivileges function enables or disables privileges in the specified access token. Enabling or disabling privileges in an access token requires TOKEN_ADJUST_PRIVILEGES access.

BOOL AdjustTokenPrivileges(

HANDLE TokenHandle, // handle to token that contains privileges
BOOL DisableAllPrivileges, // flag for disabling all privileges
PTOKEN_PRIVILEGES NewState, // pointer to new privilege information
DWORD BufferLength, // size, in bytes, of the PreviousState buffer
PTOKEN_PRIVILEGES PreviousState, // receives original state of changed privileges
PDWORD ReturnLength // receives required size of the PreviousState buffer
);


Parameters

TokenHandle

Identifies the access token that contains the privileges to be modified.

DisableAllPrivileges

Specifies whether the function disables all of the token's privileges. If this value is TRUE, the function disables all privileges and ignores the NewState parameter. If it is FALSE, the function modifies privileges based on the information pointed to by the NewState parameter.

NewState

Pointer to a TOKEN_PRIVILEGES structure that specifies an array of privileges and their attributes. If the DisableAllPrivileges parameter is FALSE, AdjustTokenPrivileges enables or disables these privileges for the token. If you set the SE_PRIVILEGE_ENABLED attribute for a privilege, the function enables that privilege; otherwise, it disables the privilege.
If DisableAllPrivileges is TRUE, the function ignores this parameter.

BufferLength

Specifies the size, in bytes, of the buffer pointed to by the PreviousState parameter. This parameter can be NULL if the PreviousState parameter is NULL.

PreviousState

Pointer to a buffer that the function fills with a TOKEN_PRIVILEGES structure containing the previous state of any privileges the function modifies. The token must be open for TOKEN_QUERY access to use this parameter. This parameter can be NULL.
If you specify a buffer that is too small to receive the complete list of modified privileges, the function fails and does not adjust any privileges. In this case, the function sets the variable pointed to by the ReturnLength parameter to the number of bytes required to hold the complete list of modified privileges.

ReturnLength

Pointer to a variable that receives the required size, in bytes, of the buffer pointed to by the PreviousState parameter. This parameter can be NULL if PreviousState is NULL.



Return Values

If the function succeeds, the return value is nonzero. To determine whether the function adjusted all of the specified privileges, call GetLastError, which returns one of the following values when the function succeeds:

Value Description
ERROR_SUCCESS The function adjusted all specified privileges.
ERROR_NOT_ALL_ASSIGNED The token does not have one or more of the privileges specified in the NewState parameter. The function may succeed with this error value even if no privileges were adjusted. The PreviousState parameter indicates the privileges that were adjusted.


If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

The AdjustTokenPrivileges function cannot add new privileges to the access token. It can only enable or disable the token's existing privileges. To determine the token's privileges, call the GetTokenInformation function.
Note that the NewState parameter can specify privileges that the token does not have, without causing the function to fail. In this case, the function adjusts the privileges that the token does have, ignores the other privileges, and returns success. Call the GetLastError function to determine whether the function adjusted all of the specified privileges. The PreviousState parameter indicates the privileges that were adjusted.

The PreviousState parameter retrieves a TOKEN_PRIVILEGES structure containing the the original state of the adjusted privileges. To restore the original state, pass the PreviousState pointer as the NewState parameter in a subsequent call to the AdjustTokenPrivileges function

myclife 2002-08-10
  • 打赏
  • 举报
回复
API是区分大小写的:
FUNCTION ulong ExitWindowsEx(ulong uFlags,ulong dwReserved) LIBRARY "user32.dll"
hjd_cw 2002-08-10
  • 打赏
  • 举报
回复
看不出有什么错误。
错误信息能否再具体一点?
liulee 2002-08-10
  • 打赏
  • 举报
回复
查看函数备注:

Windows NT: To shut down or restart the system, the calling process must use the AdjustTokenPrivileges function to enable the SE_SHUTDOWN_NAME privilege. For more information about security privileges, see Privileges.

Windows NT: 要关闭或重起系统,调用的进程必须试用 AdjustTokenPrivileges 函数来激活 SE_SHUTDOWN_NAME 权限,查看更多安全权限消息,请查看连接: Privileges

所以,要想在NT/2K/XP 下关闭系统,有很多事情要处理的.
xjl 2002-08-10
  • 打赏
  • 举报
回复
我不敢写了
嘻嘻

1,075

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder 相关问题讨论
社区管理员
  • 基础类社区
  • WorldMobile
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧