English 中文(简体)
Obtaining a proc pointer to a Carbon API at runtime
原标题:

I have a Mac application that I must build against the Mac OS 10.4 SDK for various reasons beyond my control. Given that my application s minimum OS version will be 10.5. (I know, I know... but I can t give any more details than the above to justify why this is the case.)

Within the Mac OS 10.5 SDK is an API, FSMatchAliasBulk, for which I cannot find a good equivalent in the 10.4 SDK. Knowing that I will be running on Mac OS >= 10.5, how can I get access to the FSMatchAliasBulk at runtime?

最佳回答

First, check out "How Cross-Development Works" in your Xcode Help by selecting "Developer Documentation" from the Xcode Help menu. In the documentation window, type "How Cross-Development Works" and hit return. There you will see more information.

And here is what I think you ll need to do: load the CoreServices framework and then get the function pointer for that function if you know that you re running on Mac OS X 10.5 (check out the Gestalt functionality to determine that).

Here is a sample that is not tested, but should lead you in the right direction:

CFBundleRef systemBundle = NULL;

short result = LoadFrameworkBundle(CFSTR("CoreServices.framework"), &systemBundle);

if (result == 0) {
 typedef OSStatus (FSMatchAliasBulkProcPtr) (const FSRef*, unsigned long, AliasHandle, short*, FSRef*, Boolean*, FSAliasFilterProcPtr, void*);

 FSMatchAliasBulkProcPtr myFSMatchAliasBulk = (FSMatchAliasBulkProcPtr) CFBundleGetFunctionPointerForName(systemBundle, CFSTR("FSMatchAliasBulk"));

 if (myFSMatchAliasBulk) {
 // call FSMatchAliasBulk
    OSStatus status = myFSMatchAliasBulk(....);
 }
 }
问题回答

暂无回答




相关问题
C# Networking API s [closed]

Lately I ve been looking for a good networking API i could possibly use and/or reference some of the code within, but i have mere luck searching for some on Google/Bing. Hopefully somebody here has ...

getting XML from other domain using ASP.NET

I m fairly new to ASP.NET. And I was wondering how I could go about getting xml from a site (Kuler s API in this case), and then post the result using AJAX? So what I want here, is to be able to do a ...

Most appropriate API for URL shortening service

I ve just finished an online service for shortening URLs (in php5 with Zend Framework); you can enter an URL and you get an short URL (like tinyurl and such sites). I m thinking about the API for ...

UML Diagram to Model API

I need to create a diagram to document a RESTFul API that build, which UML diagram should I use? Thanks in advance,

How best to expose Rails methods via an API?

Let s say I have a model foo, and my model has a publish! method that changes a few properties on that model and potentially a few others too. Now, the Rails way suggests that I expose my model over ...

简讯

我是否可以使用某些软件来建立简便的航天国家服务器,最好是在 Java? 所有我都希望我的航天国家服务机在任何要求中都用同样的IP地址来回答。

About paypal express checkout api

In this picture,there are 3 main steps:SetExpressCheckout,GetExpressCheckoutDetails and DoExpressCheckoutDetails,I m now sure SetExpressCheckout is to be called by myself,what about ...

热门标签