FwpmGetAppIdFromFileName0 function

The FwpmGetAppIdFromFileName0 function retrieves an application identifier from a file name.

Syntax


DWORD WINAPI FwpmGetAppIdFromFileName0(
  _In_  const wchar_t       *fileName,
  _Out_       FWP_BYTE_BLOB **appId
);

Parameters

fileName [in]

Type: const wchar_t*

File name from which the application identifier will be retrieved.

appId [out]

Type: FWP_BYTE_BLOB**

The retrieved application identifier.

Return value

Type: DWORD

Return code/valueDescription
ERROR_SUCCESS
0

The application identifier was retrieved successfully.

FWP_E_* error code
0x80320001—0x80320039

A Windows Filtering Platform (WFP) specific error. See WFP Error Codes for details.

RPC_* error code
0x80010001—0x80010122

Failure to communicate with the remote or local firewall engine.

 

Remarks

The caller must free the returned object by a call to FwpmFreeMemory0.

FwpmGetAppIdFromFileName0 is a specific implementation of FwpmGetAppIdFromFileName. See WFP Version-Independent Names and Targeting Specific Versions of Windows for more information.

Examples

The following C++ example shows how to retrieve an application identifier using FwpmGetAppIdFromFileName0.


#include <windows.h>
#include <fwpmu.h>
#include <stdio.h>

#pragma comment(lib, "Fwpuclnt.lib")

// Hard-coded file name for demonstration purposes.
#define FILE_PATH1 L"C:\\Program Files\\SomeAppFolder\\SomeApplication.exe"


int main()
{
    DWORD  result = ERROR_SUCCESS; 
    
    FWP_BYTE_BLOB *fwpApplicationByteBlob = NULL;
     
    printf("Retrieving Id for application to allow through firewall.\n");
    result = FwpmGetAppIdFromFileName0(FILE_PATH1, &fwpApplicationByteBlob);

    if (result != ERROR_SUCCESS)
    {
        printf("FwpmGetAppIdFromFileName failed (%d).\n", result);
        return result;
    }
    else
    {
        printf("The Id is: %d\n", fwpApplicationByteBlob->data);
    }
    
    return 0;
}
// ----------------------------------------------------------------------



Requirements

Minimum supported client

Windows Vista [desktop apps only]

Minimum supported server

Windows Server 2008 [desktop apps only]

Header

Fwpmu.h

Library

Fwpuclnt.lib

DLL

Fwpuclnt.dll

See also

FWP_BYTE_BLOB

 

 

Show: