我需要使用c++获取photoshop中的活动文档文件路径?
我知道在JS中我们可以通过app.activeDocument.Path获得相同的信息,但不知道如何在c++中获得相同的信息?
发布于 2022-07-06 17:06:04
这是我在一些(相当古老的)东西中发现的!我目前正在编写的代码(不是我的,我自己还在学习Photoshop API)。最后一行是针对macOS的,不知道在Windows下会是什么样子。
SPErr error = kSPNoError;
PIActionReference ref = NULL;
PIActionDescriptor resDesc = NULL;
AliasHandle srcAlias = NULL;
error = sPSActionReference->Make(&ref);
if (error == kSPNoError && ref != NULL)
{
error = sPSActionReference->PutEnumerated(ref, classDocument, typeOrdinal, enumTarget);
}
if (error != kSPNoError) goto earlyExit;
// get all the document properties and grab the interesting ones
error = sPSActionControl->Get(&resDesc, ref);
if (error == kSPNoError && resDesc != NULL)
{
// for GetAlias() refer to PIUFile.cpp
error = sPSActionDescriptor->GetAlias(resDesc, keyFileReference,
(Handle *) srcAlias);
if (error == errAEParamMissed)
{
error = saveDocFirstErr;
goto earlyExit;
}
}
if (error != kSPNoError) goto earlyExit;
FSRef srcFSRef;
Boolean wasChanged;
error = FSResolveAlias(NULL, srcAlias, &srcFSRef, &wasChanged);https://stackoverflow.com/questions/61073238
复制相似问题