0
LaunchServices 프레임 워크를 사용하려고합니다. 불행히도 일부 기능을 사용할 수 없습니다. 예를 들어, 함수 kLSSharedFileListFavoriteItems를 성공적으로 가져 왔습니다. 그러나 LSSHaredFileListCreate 함수를로드 할 수 없습니다. 코드 :LaunchServices 프레임 워크 (mac os)를 Delphi xe4에 추가하는 방법은 무엇입니까?
unit LSSharedFileList;
interface
uses MacApi.CoreFoundation, MacApi.CocoaTypes;
const
LaunchServicesLib =
'/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/LaunchServices';
type
{$EXTERNALSYM LSSHaredFileListRef}
LSSHaredFileListRef = Pointer;
{$EXTERNALSYM LSSHaredFileListCreate}
function LSSHaredFileListCreate(inAlloccator : CFAllocatorRef; inListType : CFStringRef;
listOptions : CFTypeRef) : LSSHaredFileListRef; cdecl;
{$EXTERNALSYM kLSSharedFileListFavoriteItems}
function kLSSharedFileListFavoriteItems() : CFStringRef; cdecl;
implementation
uses Posix.Dlfcn;
var
_LSSHaredFileListCreate : Pointer = nil;
_kLSSharedFileListFavoriteItems : Pointer = nil;
_libHandle : THandle = 0;
//--------------------------------------------------------------------------------
function LSSHaredFileListCreate(inAlloccator : CFAllocatorRef; inListType : CFStringRef;
listOptions : CFTypeRef) : LSSHaredFileListRef;
begin
if not Assigned(_LSSHaredFileListCreate) then
_LSSHaredFileListCreate := dlSym(_libHandle, MarshaledAString('LSSHaredFileListCreate'));
Result := nil;//
end;
//-----------------------------------------------------------------------
function kLSSharedFileListFavoriteItems() : CFStringRef;
begin
if not Assigned(_kLSSharedFileListFavoriteItems) then
_kLSSharedFileListFavoriteItems := dlSym(_libHandle, MarshaledAString('kLSSharedFileListFavoriteItems'));
Result := CFStringRef(_kLSSharedFileListFavoriteItems^)
end;
//----------------------------
initialization
_libHandle := dlOpen(MarshaledAString(LaunchServicesLib), RTLD_LAZY);
finalization
dlclose(_libHandle)
end.
그래서, _LSSHaredFileListCreate는 항상 올바른 주소를 가지고 _kLSSharedFileListFavoriteItems 달리 nil을. 어쩌면 "LSSharedFileListCreate"는 다른 라이브러리에 포함되어 있습니까? 아이디어가 있으십니까? 감사합니다. .
꽤 오래된 주제,하지만 당신은 LaunchServices 코드가 작동 것을 얻을 관리 않았다? LSSharedFileListCreate (nil, kLSSharedFileListSessionLoginItems, nil)에 대한 호출은 최소한 엘 캐피 탄에서 실행했을 때 항상 ** nil **을 반환했습니다. 서명 된 앱 또는 서명되지 않은 앱 모두. – VGeorgiev