我正在尝试将一些C Linux代码转换为Win32 C++。我有getgid功能。如何将此 Linux C 函数转换为 Win32
?以下是getgid的文档:http://man7.org/linux/man-pages/man2/getgid.2.html
以下是使用上下文:
struct SEC_CONTEXT* scx;
scx->gid = getgid();
其中SEC_CONTEXT定义为:
struct SEC_CONTEXT {
ntfs_volume* vol;
gid_t gid; /* gid of user requesting (not the mounter) */
pid_t tid; /* thread id of thread requesting */
};
此外,这个对象scx用于ntfs_mapping函数内部,依此类推......git_t是一个简单的无符号整数。
Windows没有POSIX进程组的概念。要使该代码可移植,需要了解组 ID 的用途。
不过,作为灵感,以下是 GnuWin 如何实现它:
/* Get the real group ID of the calling process. */
gid_t
__getgid ()
{
return 0;
}
getpgid
获得一个更有用的值,因为默认情况下,Windows 按父 PID 对进程进行分组;因此组 ID 等于进程 ID 值。