所以使用CTypes我试着转换下面的代码。它使用OSType
,OSType被定义为
FourCharCode = ctypes.c_uint32
OSType = FourCharCode
QTPropertyClass = OSType
我们在这里看到它是一个usngiend字符。但我们在下面的片段中看到,他们将其定义为
const OSType kFinderSig = 'MACS';
因此,在ctypes中,将变量设置为'MACS'
将不会是cUInt32类型,但它将是char no?你知道吗
请告知。你知道吗
谢谢
https://stackoverflow.com/a/8895297/1828637
OSStatus SendFinderSyncEvent( const FSRef* inObjectRef )
{
AppleEvent theEvent = { typeNull, NULL };
AppleEvent replyEvent = { typeNull, NULL };
AliasHandle itemAlias = NULL;
const OSType kFinderSig = 'MACS';
OSStatus err = FSNewAliasMinimal( inObjectRef, &itemAlias );
if (err == noErr)
{
err = AEBuildAppleEvent( kAEFinderSuite, kAESync, typeApplSignature,
&kFinderSig, sizeof(OSType), kAutoGenerateReturnID,
kAnyTransactionID, &theEvent, NULL, "'----':alis(@@)", itemAlias );
if (err == noErr)
{
err = AESendMessage( &theEvent, &replyEvent, kAENoReply,
kAEDefaultTimeout );
AEDisposeDesc( &replyEvent );
AEDisposeDesc( &theEvent );
}
DisposeHandle( (Handle)itemAlias );
}
return err;
}
'MACS'
是字符常量,不是字符串!这段代码正在使用multi-character character constants的(可疑的)GCC扩展。你知道吗您可以使用(内置)
struct
模块在Python中再现结果:或者,只需将值硬编码为
0x4d414353
,并留下表示“MACS”的注释。你知道吗相关问题 更多 >
编程相关推荐