C ++ Windows 7套接字问题 [英] C++ Windows 7 socket problem

查看:88
本文介绍了C ++ Windows 7套接字问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨.
我正在尝试使用socket(...)函数并获得WSAEACCES =权限被拒绝
立即出错.
另外,我在管理员登录下运行VS,但是以下代码显示我不是管理员:

--------------------------------------------------

Hi.
I''m trying to use socket(...) function and get WSAEACCES=Permission denied
error right away.
Also, I run my VS under administrator login, however the following code says I am NOT an admin:

--------------------------------------------------

SID_IDENTIFIER_AUTHORITY NtAuthority = SECURITY_NT_AUTHORITY;
PSID AdministratorsGroup;
// Initialize SID.
if( !AllocateAndInitializeSid( &NtAuthority,
2,
SECURITY_BUILTIN_DOMAIN_RID,
DOMAIN_ALIAS_RID_ADMINS,
0, 0, 0, 0, 0, 0,
&AdministratorsGroup))
{
AfxMessageBox("Initializing SID Failed.");

return;
}
BOOL IsInAdminGroup = FALSE;
if( !CheckTokenMembership( NULL,
AdministratorsGroup,
&IsInAdminGroup ))
{
// Error occurred.
IsInAdminGroup = FALSE;
}
// Free SID and return.
FreeSid(AdministratorsGroup);


------------------------------------
IsInAdminGroup为FALSE.

函数GetUserName(...)返回我的登录名.

有什么建议? (在XP上运行)


------------------------------------
IsInAdminGroup is FALSE.

Function GetUserName(...) returns my login.

Any suggestions? (Worked on XP)

推荐答案

您可以检查以管理员身份运行"是否可行.
You could check if "Run as administrator" works.


>>您可以检查是否以管理员身份运行"有效.
以管理员身份运行可处理exe文件.
我应该在VS中这样做吗?我正在开发应用程序,无法以这种方式对其进行调试.有没有一种方法可以在管理员权限下进行调试.另外,也许有一种方法可以使用套接字绕过该管理层,以便它可以从任何帐户运行?
>>You could check if "Run as administrator" works.
Running as an administrator works on exe files.
Hom am I supposed to do that in VS? I am developing the app and can''t debug it this way. Is there a way to debug under admin privilege. Also, may be there is a way to use sockets bypassing that layer of admin, so it would work from any account?


检查您的Windows防火墙.把它关掉.您的程序可能被阻止.另外,请尝试关闭用户帐户控制.
Check your Windows firewall. Turn it off. Your program can be blocked. Also try to turn off User Account Control.


这篇关于C ++ Windows 7套接字问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆