GetCurrentApplicationUserModelId 함수(appmodel.h)

현재 프로세스의 애플리케이션 사용자 모델 ID 를 가져옵니다.

구문

LONG GetCurrentApplicationUserModelId(
  [in, out] UINT32 *applicationUserModelIdLength,
  [out]     PWSTR  applicationUserModelId
);

매개 변수

[in, out] applicationUserModelIdLength

입력에서 applicationUserModelId 버퍼의 크기(와이드 문자)입니다. 성공하면 null 종결자를 포함하여 사용된 버퍼의 크기입니다.

[out] applicationUserModelId

애플리케이션 사용자 모델 ID를 수신하는 버퍼에 대한 포인터입니다.

반환 값

함수가 성공하면 ERROR_SUCCESS 반환합니다. 그렇지 않으면 함수는 오류 코드를 반환합니다. 가능한 오류 코드에는 다음이 포함됩니다.

반환 코드 설명
APPMODEL_ERROR_NO_APPLICATION
프로세스에 애플리케이션 ID가 없습니다.
ERROR_INSUFFICIENT_BUFFER
버퍼가 데이터를 저장할 만큼 크지 않습니다. 필요한 크기는 applicationUserModelIdLength에 의해 지정됩니다.

설명

문자열 크기 제한에 대한 자세한 내용은 ID 상수를 참조하세요.

예제

#define _UNICODE 1
#define UNICODE 1

#include <Windows.h>
#include <appmodel.h>
#include <malloc.h>
#include <stdio.h>

int __cdecl wmain()
{
    UINT32 length = 0;
    LONG rc = GetCurrentApplicationUserModelId(&length, NULL);
    if (rc != ERROR_INSUFFICIENT_BUFFER)
    {
        if (rc == APPMODEL_ERROR_NO_APPLICATION)
            wprintf(L"Desktop application\n");
        else
            wprintf(L"Error %d in GetCurrentApplicationUserModelId\n", rc);
        return 1;
    }

    PWSTR fullName = (PWSTR) malloc(length * sizeof(*fullName));
    if (fullName == NULL)
    {
        wprintf(L"Error allocating memory\n");
        return 2;
    }

    rc = GetCurrentApplicationUserModelId(&length, fullName);
    if (rc != ERROR_SUCCESS)
    {
        wprintf(L"Error %d retrieving ApplicationUserModelId\n", rc);
        return 3;
    }
    wprintf(L"%s\n", fullName);

    free(fullName);

    return 0;
}

요구 사항

요구 사항
대상 플랫폼 Windows
헤더 appmodel.h
라이브러리 Kernel32.lib
DLL Kernel32.dll

참고 항목

GetApplicationUserModelId

GetCurrentPackageFullName