資格プロバイダの名前付きパイプを使用してWindowsサービスと通信しようとしていますが、名前付きパイプコードをCOMインターフェイスの構造内に配置する場所がわかりません。私がテストベッドとして(マイクロソフトから)SampleHardwareEventCredentialProviderを使用している、と私はCSampleCredential.cpp内に以下のコードを作成しました:資格プロバイダと名前付きパイプ
// Initializes one credential with the field information passed in.
// Set the value of the SFI_USERNAME field to pwzUsername.
HRESULT CSampleCredential::Initialize(
CREDENTIAL_PROVIDER_USAGE_SCENARIO cpus,
const CREDENTIAL_PROVIDER_FIELD_DESCRIPTOR* rgcpfd,
const FIELD_STATE_PAIR* rgfsp
)
{
HRESULT hr = S_OK;
_cpus = cpus;
// Copy the field descriptors for each field. This is useful if you want to vary the field
// descriptors based on what Usage scenario the credential was created for.
for (DWORD i = 0; SUCCEEDED(hr) && i < ARRAYSIZE(_rgCredProvFieldDescriptors); i++)
{
_rgFieldStatePairs[i] = rgfsp[i];
hr = FieldDescriptorCopy(rgcpfd[i], &_rgCredProvFieldDescriptors[i]);
}
// Initialize named pipe
if (SUCCEEDED(hr)) {
HANDLE pipe = CreateNamedPipe("\\\\.\\pipe\\PipeData", PIPE_ACCESS_INBOUND | PIPE_ACCESS_OUTBOUND, PIPE_WAIT, 1, 1024, 1024, 120 * 1000, NULL);
if (pipe == INVALID_HANDLE_VALUE)
{
cout << "Error: " << GetLastError();
}
char data[1024];
DWORD numRead;
ConnectNamedPipe(pipe, NULL);
ReadFile(pipe, data, 1024, &numRead, NULL);
}
これは明らかに動作しません、私は間違った場所にかどうか、それを配置することだしない限り、 CPを初期化してWindowsサービスからの着信メッセージを待ち受けますか?どうすればいい?