If this is your code:
STRTYPE key;
hr = IsActivated(TA_GUID);
if (hr == TA_OK) {
hr = GetPKey(key, 35);
Then, there's no buffer allocated (if you're lucky the compiler is setting "key" to NULL, if you're not lucky then a random number will be in "key", and TurboActivate will write to that random pointer (causing either a segfault in your app, or causing other random memory in your app to be overwritten and eventually causing a crash).
So, initialize the "key" with a buffer of the correct size (see "API\C\Example.c" for an example showing how to do it with custom license fields -- the same thing applies for GetPKey):
TCHAR * featureValue;
hr = GetFeatureValue(_T("your feature value"), 0, 0);
featureValue = (TCHAR *)malloc(hr * sizeof(TCHAR));
hr = GetFeatureValue(_T("your feature value"), featureValue, hr);
if (hr == TA_OK) {#ifdef _WIN32 wprintf(L"Feature value: %s\n", featureValue);#else printf("Feature value: %s\n", featureValue);#endif } else printf("Getting feature failed: %d\n", hr);
free(featureValue);
The important line you're missing is this:
featureValue = (TCHAR *)malloc(hr * sizeof(TCHAR));
Or, in your case:
key = (TCHAR *)malloc(sizeOfBuffer * sizeof(TCHAR));