다음을 통해 공유


문자 및 애니메이션 데이터 로드

[Microsoft 에이전트는 Windows 7을 기준으로 더 이상 사용되지 않으며 이후 버전의 Windows에서는 사용할 수 없습니다.]

IAgentEx 인터페이스에 대한 포인터가 있으면 Load 메서드를 사용하여 문자를 로드하고 해당 IAgentCharacterEx 인터페이스를 검색할 수 있습니다. 문자의 로드 경로에는 세 가지 가능성이 있습니다. 첫 번째는 지정된 경로가 문자 파일의 전체 경로 및 파일 이름인 Microsoft 에이전트 1.5와 호환됩니다. 두 번째 가능성은 파일 이름만 지정하는 것입니다. 이 경우 에이전트는 해당 Chars 디렉터리를 찾습니다. 마지막 가능성은 기본 문자가 로드되도록 하는 빈 Variant 매개 변수를 제공하는 것입니다.

   // Create a variant to store the filename of the character to load

   const LPWSTR kpwszCharacter = L"merlin.acs";

   VariantInit(&vPath);

   vPath.vt = VT_BSTR;
   vPath.bstrVal = SysAllocString(kpwszCharacter);

   // Load the character

   hRes = pAgentEx->Load(vPath, &lCharID, &lRequestID);

   // Get its IAgentCharacterEx interface

   hRes = pAgentEx->GetCharacterEx(lCharID, &pCharacterEx);

이 인터페이스를 사용하여 문자의 메서드에 액세스할 수 있습니다.

   // Show the character.  The first parameter tells Microsoft
   // Agent to show the character by playing an animation.

   hRes = pCharacterEx->Show(FALSE, &lRequestID);

   // Make the character speak

   bszSpeak = SysAllocString(L"Hello World!");

   hRes = pCharacterEx->Speak(bszSpeak, NULL, &lRequestID);

   SysFreeString(bszSpeak);

클라이언트 애플리케이션이 종료되는 경우와 같이 Microsoft 에이전트 서비스가 더 이상 필요하지 않은 경우 해당 인터페이스를 해제합니다. 문자 인터페이스를 해제해도 문자는 언로드되지 않습니다. IAgentEx 인터페이스를 해제하기 전에 Unload 메서드를 호출하여 이 작업을 수행합니다.

// Clean up

if (pCharacterEx) {

   // Release the character interface

   pCharacterEx->Release();

   // Unload the character.  NOTE:  releasing the character
   // interface does NOT make the character go away.  You must
   // call Unload.

   pAgentEx->Unload(lCharID);
}
   
// Release the Agent

pAgentEx->Release();

VariantClear(&vPath);