#include "../wfassoc/wfassoc.h" #include #define COMMAND_MAX_LENGTH 128 WFAPP_PROFILEW* create_profile(); WCHAR* create_progId(); void* free_profile(WFAPP_PROFILEW* profile); int main(int argc, char* args[]) { // alloc input string and check it char* input_str = malloc(sizeof(char) * (COMMAND_MAX_LENGTH + 1)); if (input_str == NULL) return; // accept input while (TRUE) { gets_s(input_str, COMMAND_MAX_LENGTH); if (!strcmp(input_str, "install")) { } else if (!strcmp(input_str, "uninstall")) { } else if (!strcmp(input_str, "quit")) { break; } } //free input string free(input_str); } WFAPP_PROFILEW* create_profile() { WFAPP_PROFILEW* profile = (WFAPP_PROFILEW*)malloc(sizeof(WFAPP_PROFILEW)); if (profile == NULL) return NULL; memset(profile, 0, sizeof(WFAPP_PROFILEW)); profile->WFVersion = WFVERSION; profile->AppPath = L""; profile->AppCommand = L""; profile->SupportedTypes = L".png\0.jpg\0"; profile->ProgID = create_progId(); if (profile->ProgID == NULL) { free_profile(profile); return NULL; } return profile; } wchar_t* create_progId() { WCHAR* progid; int progIdSize; if (WFFAILED(WFGenerateProgIDW(L"PineapplePicture", L"Image", 0, NULL, &progIdSize))) { return NULL; } progid = (WCHAR*)malloc(sizeof(WCHAR) * progIdSize); if (progid == NULL) return NULL; if (WFFAILED(WFGenerateProgIDW(L"PineapplePicture", L"Image", 0, NULL, &progIdSize))) { free(progid); return NULL; } return progid; } void* free_profile(WFAPP_PROFILEW* profile) { if (profile->ProgID != NULL) free(profile->ProgID); free(profile); }