add progId generator and example
This commit is contained in:
@ -1,10 +1,26 @@
|
||||
#include "wfassoc.h"
|
||||
#include <strsafe.h>
|
||||
|
||||
// private function and variable declearions.
|
||||
|
||||
/// <summary>
|
||||
/// Convert multi byte string to wide char string
|
||||
/// Notice: this function will allocate memory for returns and it should be released safely.
|
||||
/// </summary>
|
||||
/// <param name="source">The string will be converted</param>
|
||||
/// <param name="error">The error happend during converting</param>
|
||||
/// <returns>The string has been converted. If return NULL, it mean that the converting failed.</returns>
|
||||
WCHAR* ConvMultiByteToWideChar(CHAR* source);
|
||||
|
||||
#define LEGACY_PROGID_FORMATA "%s.%s.%d"
|
||||
#define LEGACY_PROGID_FORMATW L"%s.%s.%d"
|
||||
#define SAFE_FREE(obj) if(obj!=NULL)free(obj);
|
||||
|
||||
// public function implements.
|
||||
|
||||
WFERROR WFInstallApplicationW(WFAPP_PROFILEW* profile) {
|
||||
if (profile->WFVersion != WFVERSION) return WFERROR_INVALID_VERSION;
|
||||
|
||||
return WFERROR_OK;
|
||||
}
|
||||
|
||||
@ -13,6 +29,8 @@ WFERROR WFInstallApplicationA(WFAPP_PROFILEA* profile) {
|
||||
}
|
||||
|
||||
WFERROR WFUninstallApplicationW(WFAPP_PROFILEW* profile) {
|
||||
if (profile->WFVersion != WFVERSION) return WFERROR_INVALID_VERSION;
|
||||
|
||||
return WFERROR_OK;
|
||||
}
|
||||
|
||||
@ -41,3 +59,27 @@ WFERROR WFGenerateProgIDA(CHAR* vendor, CHAR* component, INT version, CHAR* resu
|
||||
}
|
||||
return WFERROR_OK;
|
||||
}
|
||||
|
||||
|
||||
// private function and variable implements.
|
||||
|
||||
WCHAR* ConvMultiByteToWideChar(CHAR* source) {
|
||||
WCHAR* dest = NULL;
|
||||
size_t sourceLength = strlen(source);
|
||||
|
||||
int destLength = MultiByteToWideChar(CP_ACP, 0, source, sourceLength, NULL, 0);
|
||||
if (destLength <= 0) return NULL;
|
||||
destLength += 10;
|
||||
|
||||
dest = (WCHAR*)malloc(sizeof(WCHAR) * destLength);
|
||||
if (dest == NULL) return NULL;
|
||||
|
||||
memset(dest, 0, sizeof(WCHAR) * destLength);
|
||||
int error = MultiByteToWideChar(CP_ACP, 0, source, sourceLength, dest, destLength);
|
||||
if (error <= 0) {
|
||||
free(dest);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return dest;
|
||||
}
|
Reference in New Issue
Block a user