我正在尝试使用OSX上的Core Foundation库来使用它。
然而,我发现许可证验证确实不一致,有时它会使用完全相同的文件进行验证,然后有时候验证不正确。
以下是我目前正在使用的代码:
- (void)checkApexProcess{
CFMutableStringRef key = CFStringCreateMutable(NULL, 0);
CFStringAppend(key, CFSTR("0xB57B7D0E180"));
CFStringAppend(key, CFSTR("E"));
CFStringAppend(key, CFSTR("E"));
CFStringAppend(key, CFSTR("C4FD9AAAFC389F8"));
CFStringAppend(key, CFSTR("438903BC20D0"));
CFStringAppend(key, CFSTR("E"));
CFStringAppend(key, CFSTR("E"));
CFStringAppend(key, CFSTR("1F02C25010F8F47C"));
CFStringAppend(key, CFSTR("86"));
CFStringAppend(key, CFSTR("C"));
CFStringAppend(key, CFSTR("C"));
CFStringAppend(key, CFSTR("4FABF44A4376945C6F8F92292B"));
CFStringAppend(key, CFSTR("D45043012F6959BD6D3E1D246D1C1B"));
CFStringAppend(key, CFSTR("6F4A53FA1C023B4A91BC4578504B1D"));
CFStringAppend(key, CFSTR("9BEA69A53FAE91FD36ACA165CA57"));
CFStringAppend(key, CFSTR("B"));
CFStringAppend(key, CFSTR("B"));
CFStringAppend(key, CFSTR(""));
CFStringAppend(key, CFSTR("B"));
CFStringAppend(key, CFSTR("4"));
CFStringAppend(key, CFSTR("4"));
CFStringAppend(key, CFSTR("C30A925FAFBB1CA595D5011DA0E"));
CFStringAppend(key, CFSTR("BF819BC6A909861DE8C5121FCA06AF"));
CFStringAppend(key, CFSTR("FB3290875E3ED23D1F"));
APSetKey(key);
NSURL* filePath;
NSOpenPanel* openDlg = [NSOpenPanel openPanel];
[openDlg setCanChooseFiles:YES];
[openDlg setCanChooseDirectories:NO];
CFURLRef filePathUrl;
bool Valid;
//CFDictionaryRef cfUserLicenseInfo;
NSDictionary* apexDict;
if ( [openDlg runModal] == NSOKButton )
{
for( NSURL* URL in [openDlg URLs] )
{
filePath = URL;
NSString* filePathString = [URL path];
filePathUrl = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, (CFStringRef) filePathString, kCFURLPOSIXPathStyle, FALSE);
//CFDictionaryRef cfUserLicenseInfo = APCreateDictionaryForLicenseFile(filePathUrl);
Valid = APVerifyLicenseFile(filePathUrl);
//Valid = APVerifyLicenseData(cfUserLicenseInfo);
DDLogCVerbose( @"%@", filePath );
DDLogCVerbose( @"%@", filePathUrl );
DDLogCVerbose( @"%@", [URL path] );
//apexDict = [NSDictionary dictionaryWithContentsOfFile:(filePathString)];
}
//Valid = testValidLicenseFile2(filePathUrl);
if(Valid == true){
//[self storeLicenseFile:filePath];
[self enableApexButtons];
} else {
[self displayApexAlertInvalid];
[self removeApexFile];
}
}
}
我真的被困在这里发生了什么,我真的不明白它有时会如何验证,而不是其他人?
有人有任何想法吗?
由于
加雷
修改1
奇怪的是,如果我发表评论:
CFDictionaryRef cfUserLicenseInfo;
NSDictionary* apexDict;
然后验证通过,如果没有那么它失败了,这是非常奇怪的,任何人都有任何想法?