I am trying to call the Winapi function NetGroupGetUsers:
The NetGroupGetUsers function retrieves a list of the members in a particular global group in the security database, which is the security accounts manager (SAM) database or, in the case of domain controllers, the Active Directory.
I’ve tried calling the function with every variation of serverName and groupName i can think of:
| ServerName | GroupName | Error code | Description |
|---|---|---|---|
| null | docker-users | 2220 | The group name could not be found |
| null | OBSIDIANdocker-users | 2220 | The group name could not be found |
| null | .docker-users | 2220 | The group name could not be found |
| OBSIDIAN | docker-users | 2220 | The group name could not be found |
| OBSIDIAN | OBSIDIANdocker-users | 2220 | The group name could not be found |
| OBSIDIAN | .docker-users | 2220 | The group name could not be found |
| . | docker-users | 2220 | The group name could not be found |
| . | OBSIDIANdocker-users | 2220 | The group name could not be found |
| . | .docker-users | 2220 | The group name could not be found |
Where the error code 2220 corresponds to the constant:
NERR_GroupNotFound: The global group name in the structure pointed to by bufptr parameter could not be found.
Long Version
There is a group on my local workstation called docker-users:
>whoami /groups
GROUP INFORMATION
-----------------
Group Name Type SID Attributes
===================== ===== ============================================= ==================================================
OBSIDIANdocker-users Alias S-1-5-21-502352433-3072756349-3142140079-1006 Mandatory group, Enabled by default, Enabled group
And you can see the group members in netplwiz:

You can also see the group members in the Local Users and Groups MMC snap-in.
- Starting with the SID (e.g.
S-1-5-21-502352433-3072756349-3142140079-1006) - Then call LookupAccountSID to have it return:
- DomainName
- AccountName
- SID type
- If the SidType represents a group (i.e. SidTypeAlias, SidTypeWellKnownGroup, or SidTypeGroup — which all mean «group»)
We want the group members. So we call NetGroupGetUsers:
NetGroupGetUsers(null, "DomainNameAccountName", 1, out buffer, MAX_PREFERRED_LENGTH, out entriesRead, out totalEntries, null);
Except it fails. Every time. No matter what.
The question
Why does the call fail?
What is the correct way to specify:
- Server name
- group name
Of course, for all i know it could be an ABI alignment issue. The only way to find out is if someone else tries calling the function on their local (domain joined or non-domain joined PC — doesn’t matter).
CRME for the lazy
program GetGroupUsersDemo;
{$APPTYPE CONSOLE}
{$R *.res}
uses
System.SysUtils,
Windows;
function NetGroupGetUsers(servername: LPCWSTR; groupname: LPCWSTR; level: DWORD;
out bufptr: Pointer; prefmaxlen: DWORD; out entriesread: DWORD;
out totalentries: DWORD; ResumeHandle: PDWORD): DWORD; stdcall; external 'netapi32.dll';
function GetGroupMembers(ServerName, GroupName: UnicodeString): HRESULT;
var
res: DWORD; {NET_API_STATUS}
buf: Pointer;
entriesRead: DWORD;
totalEntries: DWORD;
i: Integer;
server: PWideChar;
const
MAX_PREFERRED_LENGTH = Cardinal(-1);
begin
server := PWideChar(ServerName);
if server = '' then
server := nil;
res := NetGroupGetUsers(server, PWideChar(GroupName), 1,
{var}buf,
MAX_PREFERRED_LENGTH, //Let the function allocate everything for us
{var}entriesRead,
{var}totalEntries,
nil);
Result := HResultFromWin32(res);
end;
procedure Test(ServerName, GroupName: UnicodeString);
var
hr: HRESULT;
s: string;
begin
hr := GetGroupMembers(ServerName, GroupName);
s := ServerName;
if s = '' then
s := 'null'; //can't have people not reading the question
Writeln('| '+s+' | '+GroupName+' | '+IntToStr(hr and $0000FFFF)+' | '+SysErrorMessage(hr)+' |');
end;
procedure Main;
begin
Writeln('| ServerName | GroupName | Error code | Description |');
Writeln('|------------|-----------|------------|-------------|');
Test('', 'OBSIDIANdocker-users');
Test('', '.docker-users');
Test('OBSIDIAN', 'docker-users');
Test('OBSIDIAN', 'OBSIDIANdocker-users');
Test('OBSIDIAN', '.docker-users');
Test('.', 'docker-users');
Test('.', 'OBSIDIANdocker-users');
Test('.', '.docker-users');
end;
begin
try
Main;
Readln;
except
on E: Exception do
Writeln(E.ClassName, ': ', E.Message);
end;
end.
Bonus Reading
- How to get members of a Windows (security) group?
- Usage of NetGroupGetUsers
- https://www.experts-exchange.com/questions/21985159/Group-not-found-error-on-NetGroupGetUsers.html
- https://www.experts-exchange.com/questions/11273935/NetGroupGetUsers-API.html
- https://microsoft.public.vb.winapi.networks.narkive.com/ssfpNHJR/problem-with-local-groups
- https://forum.powerbasic.com/forum/user-to-user-discussions/powerbasic-for-windows/5791-newbeeeeee-help-please
I am trying to call the Winapi function NetGroupGetUsers:
The NetGroupGetUsers function retrieves a list of the members in a particular global group in the security database, which is the security accounts manager (SAM) database or, in the case of domain controllers, the Active Directory.
I’ve tried calling the function with every variation of serverName and groupName i can think of:
| ServerName | GroupName | Error code | Description |
|---|---|---|---|
| null | docker-users | 2220 | The group name could not be found |
| null | OBSIDIANdocker-users | 2220 | The group name could not be found |
| null | .docker-users | 2220 | The group name could not be found |
| OBSIDIAN | docker-users | 2220 | The group name could not be found |
| OBSIDIAN | OBSIDIANdocker-users | 2220 | The group name could not be found |
| OBSIDIAN | .docker-users | 2220 | The group name could not be found |
| . | docker-users | 2220 | The group name could not be found |
| . | OBSIDIANdocker-users | 2220 | The group name could not be found |
| . | .docker-users | 2220 | The group name could not be found |
Where the error code 2220 corresponds to the constant:
NERR_GroupNotFound: The global group name in the structure pointed to by bufptr parameter could not be found.
Long Version
There is a group on my local workstation called docker-users:
>whoami /groups
GROUP INFORMATION
-----------------
Group Name Type SID Attributes
===================== ===== ============================================= ==================================================
OBSIDIANdocker-users Alias S-1-5-21-502352433-3072756349-3142140079-1006 Mandatory group, Enabled by default, Enabled group
And you can see the group members in netplwiz:

You can also see the group members in the Local Users and Groups MMC snap-in.
- Starting with the SID (e.g.
S-1-5-21-502352433-3072756349-3142140079-1006) - Then call LookupAccountSID to have it return:
- DomainName
- AccountName
- SID type
- If the SidType represents a group (i.e. SidTypeAlias, SidTypeWellKnownGroup, or SidTypeGroup — which all mean «group»)
We want the group members. So we call NetGroupGetUsers:
NetGroupGetUsers(null, "DomainNameAccountName", 1, out buffer, MAX_PREFERRED_LENGTH, out entriesRead, out totalEntries, null);
Except it fails. Every time. No matter what.
The question
Why does the call fail?
What is the correct way to specify:
- Server name
- group name
Of course, for all i know it could be an ABI alignment issue. The only way to find out is if someone else tries calling the function on their local (domain joined or non-domain joined PC — doesn’t matter).
CRME for the lazy
program GetGroupUsersDemo;
{$APPTYPE CONSOLE}
{$R *.res}
uses
System.SysUtils,
Windows;
function NetGroupGetUsers(servername: LPCWSTR; groupname: LPCWSTR; level: DWORD;
out bufptr: Pointer; prefmaxlen: DWORD; out entriesread: DWORD;
out totalentries: DWORD; ResumeHandle: PDWORD): DWORD; stdcall; external 'netapi32.dll';
function GetGroupMembers(ServerName, GroupName: UnicodeString): HRESULT;
var
res: DWORD; {NET_API_STATUS}
buf: Pointer;
entriesRead: DWORD;
totalEntries: DWORD;
i: Integer;
server: PWideChar;
const
MAX_PREFERRED_LENGTH = Cardinal(-1);
begin
server := PWideChar(ServerName);
if server = '' then
server := nil;
res := NetGroupGetUsers(server, PWideChar(GroupName), 1,
{var}buf,
MAX_PREFERRED_LENGTH, //Let the function allocate everything for us
{var}entriesRead,
{var}totalEntries,
nil);
Result := HResultFromWin32(res);
end;
procedure Test(ServerName, GroupName: UnicodeString);
var
hr: HRESULT;
s: string;
begin
hr := GetGroupMembers(ServerName, GroupName);
s := ServerName;
if s = '' then
s := 'null'; //can't have people not reading the question
Writeln('| '+s+' | '+GroupName+' | '+IntToStr(hr and $0000FFFF)+' | '+SysErrorMessage(hr)+' |');
end;
procedure Main;
begin
Writeln('| ServerName | GroupName | Error code | Description |');
Writeln('|------------|-----------|------------|-------------|');
Test('', 'OBSIDIANdocker-users');
Test('', '.docker-users');
Test('OBSIDIAN', 'docker-users');
Test('OBSIDIAN', 'OBSIDIANdocker-users');
Test('OBSIDIAN', '.docker-users');
Test('.', 'docker-users');
Test('.', 'OBSIDIANdocker-users');
Test('.', '.docker-users');
end;
begin
try
Main;
Readln;
except
on E: Exception do
Writeln(E.ClassName, ': ', E.Message);
end;
end.
Bonus Reading
- How to get members of a Windows (security) group?
- Usage of NetGroupGetUsers
- https://www.experts-exchange.com/questions/21985159/Group-not-found-error-on-NetGroupGetUsers.html
- https://www.experts-exchange.com/questions/11273935/NetGroupGetUsers-API.html
- https://microsoft.public.vb.winapi.networks.narkive.com/ssfpNHJR/problem-with-local-groups
- https://forum.powerbasic.com/forum/user-to-user-discussions/powerbasic-for-windows/5791-newbeeeeee-help-please
I’ve recently moved a large codebase from VS2013 to VS2019 that builds for windows 32 and 64 bit targets.
Debug and release versions compile with numerous warnings, although these are largely the same as existed in the VS2013 build. Most of them are trivial issues that I know to be safe. I’m compiling with the «W3» compiler option.
However when I attempt to compile an «analyze» version of the build, (I include the «/analyze» compiler option) I get many of the following:
error C2220: the following warning is treated as an error
That’s to be expected, and some of those errors needed attention. But the first thing that seems strange is that MANY of those «errors» were from the windows SDK libraries — code I’m not exactly prepared to edit.
Then I read the following:
https://learn.microsoft.com/en-us/cpp/build/reference/analyze-code-analysis?view=vs-2019
So I amended «/analyze» to /analyze:WX-«, just for the sake of experimenting. This silenced a LOT of the errors, but I still get a number of «Error C2220: the following warning is treated as an error», mostly in 3rd party libraries. I’m happy to fix (or ignore where appropriate) issues that have come up in my own code.
So my question is, how do I suppress this error when it is cropping up in things like the windows SDK and very well-used 3rd party libraries? That fact that this isn’t more of an issue makes me suspect I’ve missed something here. But I currently can’t get through a code analysis, which was really not problematic in VS2013.
I’ve recently moved a large codebase from VS2013 to VS2019 that builds for windows 32 and 64 bit targets.
Debug and release versions compile with numerous warnings, although these are largely the same as existed in the VS2013 build. Most of them are trivial issues that I know to be safe. I’m compiling with the «W3» compiler option.
However when I attempt to compile an «analyze» version of the build, (I include the «/analyze» compiler option) I get many of the following:
error C2220: the following warning is treated as an error
That’s to be expected, and some of those errors needed attention. But the first thing that seems strange is that MANY of those «errors» were from the windows SDK libraries — code I’m not exactly prepared to edit.
Then I read the following:
https://learn.microsoft.com/en-us/cpp/build/reference/analyze-code-analysis?view=vs-2019
So I amended «/analyze» to /analyze:WX-«, just for the sake of experimenting. This silenced a LOT of the errors, but I still get a number of «Error C2220: the following warning is treated as an error», mostly in 3rd party libraries. I’m happy to fix (or ignore where appropriate) issues that have come up in my own code.
So my question is, how do I suppress this error when it is cropping up in things like the windows SDK and very well-used 3rd party libraries? That fact that this isn’t more of an issue makes me suspect I’ve missed something here. But I currently can’t get through a code analysis, which was really not problematic in VS2013.
У меня есть ниже класс:
class Cdata12Mnt
{
public:
char IOBname[ID1_IOB_PIOTSUP-ID1_IOB_TOP][BOADNAM_MAX + 4];
char ExIOBname[ID1_MAX_INF-ID1_EXIOB_U1TOP][BOADNAM_MAX + 4];
char cflpath[256];
char basetext[256];
UINT database[ID1_MAX_INF];
int State;
public:
char SelectPath[256];
public:
int GetIOBName(int slt,char *Name);
Cdata12Mnt(char *SelectPath);
virtual ~Cdata12Mnt();
int GetValue(int id);
int GetState() { return State; }
};
И у меня есть функция как ниже:
Cdata12Mnt::Cdata12Mnt(char *SelectPath)
{
SCTReg reg;
char buf[256], *cpnt, *npnt, *bpnt1, *bpnt2;
char *startcode[] = {"CNTL_CODE ","SEGMENT "};
char *stopcode = {"END_CNTL_CODE "};
FILE *fp;
int ii, infl;
State = 0;
for (ii = 0; ii < (ID1_IOB_PIOTSUP - ID1_IOB_TOP); ii++) {
strcpy(IOBname[ii], "");
}
for (ii = 0; ii < (ID1_MAX_INF-ID1_EXIOB_U1TOP); ii++) {
**strcpy(ExIOBname[ii], "");**
}
sprintf(cflpath, "%s\%s", SelectPath, CDATAFL);
if ((fp = fopen(cflpath,"r"))!=NULL) {
for (ii = 0, infl = 0; fgets(buf, 256, fp) != NULL;) {
if (infl == 0 && strncmp(buf, startcode[0], strlen(startcode[0])) == 0) {
if ((cpnt = strchr(&buf[strlen(startcode[0])],*startcode[1])) != NULL) {
if (strncmp(cpnt,startcode[1], strlen(startcode[1])) == 0) {
infl = 1;
continue;
}
}
}
if (infl == 0) {
continue;
}
if (strncmp(buf,stopcode,strlen(stopcode))==0) {
if (ii == ID1_EXIOB_U1TOP) {
for (int nDataNumber = ii; nDataNumber < ID1_MAX_INF; nDataNumber++) {
database[nDataNumber] = 0;
}
}
infl = 0;
continue;
}
if (strncmp(&buf[14], " DD ", 4) == 0) {
if ((cpnt=strchr(buf, ';')) != NULL) {
*cpnt = '';
}
if (ii >= ID1_IOB_TOP && ii < ID1_IOB_PIOTSUP) {
if ((bpnt1 = strchr(cpnt + 1,'(')) != NULL && (bpnt2=strchr(cpnt + 1,')'))!=NULL && bpnt1 < bpnt2) {
*bpnt2 = '';
*(bpnt1 + BOADNAM_MAX + 1) = '';
strcpy(IOBname[ii-ID1_IOB_TOP], bpnt1 + 1);
}
}
if (ii >= ID1_EXIOB_U1TOP && ii < ID1_MAX_INF) {
if ((bpnt1 = strchr(cpnt + 1, '(')) != NULL && (bpnt2=strchr(cpnt+1,')'))!=NULL && bpnt1 < bpnt2) {
*bpnt2='';
*(bpnt1+BOADNAM_MAX+1)='';
strcpy(ExIOBname[ii-ID1_EXIOB_U1TOP], bpnt1 + 1);
}
}
for (cpnt = &buf[18]; cpnt != NULL;) {
if ((npnt=strchr(cpnt, ',')) != NULL)
*npnt='';
}
if (strchr(cpnt,'H')!=NULL) {
sscanf(cpnt,"%XH",&database[ii]);
} else {
database[ii]=atoi(cpnt);
}
ii++;
cpnt = npnt;
if (cpnt != NULL) {
cpnt++;
}
}
}
}
fclose(fp);
} else {
State=-1;
}
Когда я компилирую эту функцию в Visual Studio 2008, она выдает ошибку при strcpy(IOBname[ii],""); как ниже.
ошибка C2220: предупреждение рассматривается как ошибка — файл объекта не создан
Как исправить эту ошибку?
21
Решение
Ошибка говорит о том, что предупреждение было обработано как ошибка. Поэтому ваша проблема — предупреждающее сообщение! Проверьте их и исправьте их.
Если вы не знаете, как их найти: откройте Error List (View > Error List) и нажмите на Warning,
23
Другие решения
Идти к project properties -> configurations properties -> C/C++ -> treats warning as error -> No (/WX-),
10
Это сообщение об ошибке очень запутанно. Я просто исправил другие «предупреждения» в своем проекте, и у меня действительно было только одно (простое):
предупреждение C4101: ‘i’: локальная переменная без ссылки
После того, как я прокомментировал это неиспользованным iи скомпилировал его, другая ошибка исчезла.
5
Как примечание, вы можете включить / отключить отдельные предупреждения, используя #pragma, Вы можете взглянуть на документацию Вот
Из документации:
// pragma_warning.cpp
// compile with: /W1
#pragma warning(disable:4700)
void Test() {
int x;
int y = x; // no C4700 here
#pragma warning(default:4700) // C4700 enabled after Test ends
}
int main() {
int x;
int y = x; // C4700
}
3
Это предупреждение о небезопасном использовании strcpy. Пытаться IOBname[ii]=''; вместо.
1
| Номер ошибки: | Ошибка 2220 | |
| Название ошибки: | Microsoft Office Access can’t open the file ‘|’ | |
| Описание ошибки: | Microsoft Office Access can’t open the file ‘|’.@@@1@@@1. | |
| Разработчик: | Microsoft Corporation | |
| Программное обеспечение: | Microsoft Access | |
| Относится к: | Windows XP, Vista, 7, 8, 10, 11 |
Сводка «Microsoft Office Access can’t open the file ‘|’
«Microsoft Office Access can’t open the file ‘|’» обычно называется формой «ошибки времени выполнения». Разработчики программного обеспечения пытаются обеспечить, чтобы программное обеспечение было свободным от этих сбоев, пока оно не будет публично выпущено. К сожалению, такие проблемы, как ошибка 2220, могут не быть исправлены на этом заключительном этапе.
Некоторые пользователи могут столкнуться с сообщением «Microsoft Office Access can’t open the file ‘|’.@@@1@@@1.» при использовании Microsoft Access. Во время возникновения ошибки 2220 конечный пользователь может сообщить о проблеме в Microsoft Corporation. Microsoft Corporation вернется к коду и исправит его, а затем сделает обновление доступным для загрузки. Таким образом при выполнении обновления программного обеспечения Microsoft Access, он будет содержать исправление для устранения проблем, таких как ошибка 2220.
Когда происходит ошибка 2220?
Проблема с исходным кодом Microsoft Access приведет к этому «Microsoft Office Access can’t open the file ‘|’», чаще всего на этапе запуска. Следующие три наиболее значимые причины ошибок выполнения ошибки 2220 включают в себя:
Ошибка 2220 Crash — программа обнаружила ошибку 2220 из-за указанной задачи и завершила работу программы. Обычно это происходит, когда Microsoft Access не может обрабатывать предоставленный ввод или когда он не знает, что выводить.
Утечка памяти «Microsoft Office Access can’t open the file ‘|’» — этот тип утечки памяти приводит к тому, что Microsoft Access продолжает использовать растущие объемы памяти, снижая общую производительность системы. Критическими проблемами, связанными с этим, могут быть отсутствие девыделения памяти или подключение к плохому коду, такому как бесконечные циклы.
Error 2220 Logic Error — Ошибка программной логики возникает, когда, несмотря на точный ввод от пользователя, производится неверный вывод. Это происходит, когда исходный код Microsoft Corporation вызывает уязвимость при обработке информации.
В большинстве случаев проблемы с файлами Microsoft Office Access can’t open the file ‘|’ связаны с отсутствием или повреждением файла связанного Microsoft Access вредоносным ПО или вирусом. В большинстве случаев скачивание и замена файла Microsoft Corporation позволяет решить проблему. Помимо прочего, в качестве общей меры по профилактике и очистке мы рекомендуем использовать очиститель реестра для очистки любых недопустимых записей файлов, расширений файлов Microsoft Corporation или разделов реестра, что позволит предотвратить появление связанных с ними сообщений об ошибках.
Классические проблемы Microsoft Office Access can’t open the file ‘|’
Наиболее распространенные ошибки Microsoft Office Access can’t open the file ‘|’, которые могут возникнуть на компьютере под управлением Windows, перечислены ниже:
- «Ошибка Microsoft Office Access can’t open the file ‘|’. «
- «Ошибка программного обеспечения Win32: Microsoft Office Access can’t open the file ‘|’»
- «Microsoft Office Access can’t open the file ‘|’ столкнулся с проблемой и закроется. «
- «Не удается найти Microsoft Office Access can’t open the file ‘|’»
- «Отсутствует файл Microsoft Office Access can’t open the file ‘|’.»
- «Проблема при запуске приложения: Microsoft Office Access can’t open the file ‘|’. «
- «Не удается запустить Microsoft Office Access can’t open the file ‘|’. «
- «Ошибка Microsoft Office Access can’t open the file ‘|’. «
- «Неверный путь к программе: Microsoft Office Access can’t open the file ‘|’. «
Обычно ошибки Microsoft Office Access can’t open the file ‘|’ с Microsoft Access возникают во время запуска или завершения работы, в то время как программы, связанные с Microsoft Office Access can’t open the file ‘|’, выполняются, или редко во время последовательности обновления ОС. Запись ошибок Microsoft Office Access can’t open the file ‘|’ внутри Microsoft Access имеет решающее значение для обнаружения неисправностей электронной Windows и ретрансляции обратно в Microsoft Corporation для параметров ремонта.
Создатели Microsoft Office Access can’t open the file ‘|’ Трудности
Эти проблемы Microsoft Office Access can’t open the file ‘|’ создаются отсутствующими или поврежденными файлами Microsoft Office Access can’t open the file ‘|’, недопустимыми записями реестра Microsoft Access или вредоносным программным обеспечением.
В частности, проблемы с Microsoft Office Access can’t open the file ‘|’, вызванные:
- Недопустимые разделы реестра Microsoft Office Access can’t open the file ‘|’/повреждены.
- Загрязненный вирусом и поврежденный Microsoft Office Access can’t open the file ‘|’.
- Другая программа (не связанная с Microsoft Access) удалила Microsoft Office Access can’t open the file ‘|’ злонамеренно или по ошибке.
- Другое приложение, конфликтующее с Microsoft Office Access can’t open the file ‘|’ или другими общими ссылками.
- Неполный или поврежденный Microsoft Access (Microsoft Office Access can’t open the file ‘|’) из загрузки или установки.
Продукт Solvusoft
Загрузка
WinThruster 2022 — Проверьте свой компьютер на наличие ошибок.
Совместима с Windows 2000, XP, Vista, 7, 8, 10 и 11
Установить необязательные продукты — WinThruster (Solvusoft) | Лицензия | Политика защиты личных сведений | Условия | Удаление