Stackoverflow와 PInvoke.net의 검색 용어 RpcMgmtEpEltInqNext
은 결과가 0이므로이 값을 묻는 것이 좋습니다. 나는 MSDN을 둘러보고 Windows SDK * .h 파일을 하루 종일 보며 내 요소에서 약간 벗어난 느낌을 보였다.어떻게 RpcMgmtEpEltInqNext를 실행합니까?
기본적으로 관리 코드가있는 MSRPC 끝점 매퍼를 쿼리하려고합니다. 여기 내가 지금까지 가지고있는 것입니다 :
[DllImport("Rpcrt4.dll", CharSet = CharSet.Auto)]
public static extern int RpcBindingFromStringBinding(string StringBinding, out IntPtr Binding);
[DllImport("Rpcrt4.dll")]
public static extern int RpcBindingFree(ref IntPtr Binding);
[DllImport("Rpcrt4.dll", CharSet = CharSet.Auto)]
public static extern int RpcMgmtEpEltInqBegin(IntPtr EpBinding,
int InquiryType, // 0x00000000 = RPC_C_EP_ALL_ELTS
int IfId,
int VersOption,
string ObjectUuid,
out IntPtr InquiryContext);
[DllImport("Rpcrt4.dll", CharSet = CharSet.Auto)]
public static extern int RpcMgmtEpEltInqNext(ref IntPtr InquiryContext,
out int IfId,
out IntPtr Binding,
out string ObjectUuid,
out string Annotation);
public static List<int> QueryEPM(string host)
{
List<int> ports = new List<int>();
int retCode = 0; // RPC_S_OK
IntPtr bindingHandle = IntPtr.Zero;
IntPtr inquiryContext = IntPtr.Zero;
IntPtr elementBindingHandle = IntPtr.Zero;
int elementIfId = 0;
string elementUuid = string.Empty;
string elementAnnotation = string.Empty;
try
{
retCode = RpcBindingFromStringBinding("ncacn_ip_tcp:" + host, out bindingHandle);
if (retCode != 0)
throw new Exception("RpcBindingFromStringBinding: " + retCode);
retCode = RpcMgmtEpEltInqBegin(bindingHandle, 0, 0, 0, string.Empty, out inquiryContext);
if (retCode != 0)
throw new Exception("RpcMgmtEpEltInqBegin: " + retCode);
retCode = RpcMgmtEpEltInqNext (ref inquiryContext, out elementIfId, out elementBindingHandle, out elementUuid, out elementAnnotation);
if (retCode != 0)
throw new Exception("RpcMgmtEpEltInqNext: " + retCode);
}
위의 코드는 완전하지 않지만 내 요점을 설명합니다. 코드는 지속적으로 반환
RpcMgmtEpEltIngNext : 87
87 의미 변수가 here에 따라 잘못된 것입니다.
나는 기본적으로이 시점에서 곤란을 겪고 있으며, 나는 그것이 매우 진절머리 나는 PInvoke 코드 때문이라고 확신한다.
이것은 내가 가고 싶은 곳으로 정확히 나를 데려다줍니다. 고맙습니다. –