기본 콘텐츠로 건너뛰기

[src/c++/vs2005] 현재 사용중 Windows의 로컬계정 목록들 확인


[src/c++/vs2005] 현재 사용중 Windows의 로컬계정 목록들 확인

// NetGroupEnum.cpp : 콘솔 응용 프로그램에 대한 진입점을 정의합니다.
//
// VC 콘솔 어플리케이션으로 수행했습니다.

#include "stdafx.h"
#define UNICODE
#include <windows.h>
#include <lmaccess.h>
#include <lmapibuf.h>

#include <iostream>
#pragma comment(lib, "Netapi32.lib")

int _tmain(int argc, _TCHAR* argv[])
{
LOCALGROUP_INFO_0 *l_info;
DWORD read;
DWORD total;

NetLocalGroupEnum(NULL,
0,
(unsigned char **)&l_info,
MAX_PREFERRED_LENGTH,
&read,
&total,
NULL);

std::wcout << L"[Local Groups]\n";

int i;
for (i=0; i<read; i++) {
std::wcout << l_info[i].lgrpi0_name << std::endl;

LOCALGROUP_MEMBERS_INFO_1 *members;
DWORD entries, total_entries;

NetLocalGroupGetMembers(NULL,
l_info[i].lgrpi0_name,
1,
reinterpret_cast<BYTE **>(&members),
MAX_PREFERRED_LENGTH,
&entries,
&total_entries,
NULL);

for (int mem_num = 0; mem_num<entries; mem_num++)
std::wcout << L"\t" << members[mem_num].lgrmi1_name << L"\n";
NetApiBufferFree(members);
}


NetApiBufferFree(l_info);
return 0;
}

댓글

이 블로그의 인기 게시물

[c#.net] WPF 사용 중 xaml관련 실행시 오류 와 대처 방법

wpf 사용 중 xaml관련 실행시 오류 가 발생해서 자그마치 2일을 소비 했다..--;; 오류 내용은 아래와 같다. ================================== 'System.Windows.Markup.XamlParseException' 형식의 첫째 예외가 PresentationFrameWork.dll에서 발생했습니다. 추가 정보: '지정된 바인딩 제약 조건과 일치하는 'PapaZone.MainWindow' 형식에 대한 생성자 호출에서 예외가 throw 되었습니다.' 줄 번호 '21' 및 줄 위치 '9' 이 예외에 대한 처리기가 있으면 프로그램을 안전하게 계속할 수 있습니다. [] 이 예외 형식이 throw되면 중단 ================================== 위 Xaml 오류 메세지만으로는 내용 추적 불가하여, 도대체 뭔가 했다. 검색해도 뚜렷한 답변은 없었지만, 여러가지 의견을 종합해 보면 아래와 같다. 1. xmlns 관련 파일 과 관련된 파일 로딩 실패 이거나, 2. 신규로 추가된 namespace 에 속한 태그 사용시 오류로 판단되어 태그 하나씩 삽입하며 테스트 해봐야 한다고 함. 해결한 지금에 원인을 보면, xaml 에서 clr-namespace 로 추가된 항목들이 로딩에 실패해서 발생한 것이며, 추가된 항목은 있었으나, 이것과 연결된 파일이 없어서 로딩되지 않는 것이 문제였다. 오늘도 즐거운 하루~~

golang .protobuf go_package 오류 나는 문제.

1.golang용 protocol buffer 관련 모듈은 다운로드 받았음 go get -d -u google.golang.org/protobuf go install github.com/golang/protobuf/protoc-gen-go 2. pitaya 샘플 .proto 파일 생성을 시도 했으나, 아래 오류가 발생하면서 빌드 실패함 D:\pitaya>protoc --proto_path=examples\demo\worker\protos --go_out=plugins=grpc:. examples\demo\worker\protos\*.proto protoc-gen-go: unable to determine Go import path for "arg.proto" Please specify either:         • a "go_package" option in the .proto source file, or         • a "M" argument on the command line. See https://developers.google.com/protocol-buffers/docs/reference/go-generated#package for more information. --go_out: protoc-gen-go: Plugin failed with status code 1. D:\pitaya> stackoverflow 등 참고해도 비슷하지만 다른 내용들 뿐. .proto 파일내에 option go_package = "../protos_gen"; 내용 추가하여 빌드하니 잘됨. 3.기존 소스 -------------------------------- syntax = "proto3"; package protos; message Arg {   string msg = 1; } 4.신규 소스 -------------------------------- syntax ...

Concurrency in Go 책 읽고 대략 요약

원본은 https://laced-river-472.notion.site/Concurrency-in-Go-7f97812aee104adc8cc6d60591f01316 에 요약 해놓음. 2024년 3월 27일 ~ 2024년 3월 29일 Concurrency in go 책 검토 https://github.com/SK-Jin/concurrency-in-go-src 1장 동시성 소개 동시성이 어려운 이유 2장 코드 모델링: 순차적 프로세스간의 통신(CSP) 동시성과 병렬성의 차이 동시성을 지원하는 언어의 장점 Go의 동시성의 철학 3장 동시성 구성요소 goroutine Sync Package Channels select-statement defer-statment 4장 동시성 패턴 제한(Confinement) Ad-hoc 내부적인 규칙, 암묵적인 규칙 등 시간적인 문제로 깨트려지는 경우가 있을 수 있음. lexical 도구에서 문제 상황에 대해 통보, 이를 개선 하는 형태로 접근 동기화를 사용할 수 있다면, 제한을 추구해야 함. 성능을 향상시키고, 개발자의 인지 부하를 줄이기 위함 동기화에는 비용이 들며, 이를 피할 수 있으면, 임계 염역이 없기 때문에 동기화 비용을 지불할 필요가 없음. 동기화로 인해 발생 가능한 모든 문제도 막을 수 있음 for-select 루프 채널에서 반복 변수 보내기 멈추기를 기다리면서 무한히 대기 고루틴 누수 방지 고루틴 작지만 리소스를 필요로 함. 가비지 콜렉터에 의해 수집 되지 않음. -> 원인은 제각각 이겠지만, 여전히 활성화 되어 있을 것이므로 고루틴 종료 조건 작업 완료 복구할 수 없는 에러로 인해 더 이상 작업을 계속할 수 없을 때 작업을 중단하라는 요청을 받았을 떄 -> 네트워크 효과(연관된 고루틴 존제)가 있으므로 제일 중요 접근 1 Cancel chan 생성 하여 기존 for~r...