PDA

View Full Version : Windows equivalent API in MAC




prashantmirge
Apr 7, 2008, 12:23 AM
Is there Equivalent API in MAC
for the following API's in window.
1. InitializeSecurityDescriptor
2. InterlockedCompareExchange
3. InterlockedDecrement
4. InterlockedExchange
5. InterlockedIncrement
6. IsBadReadPtr
7. IsValidCodePage
8. IsValidLocale
9. IsValidSecurityDescriptor
10. IsWindow
11. KillTimer
12. LCMapStringW
13. LeaveCriticalSection
14. LoadLibraryExW



Krevnik
Apr 7, 2008, 02:06 AM
A very unusual question... as some of these belong to a collection of APIs, and you apparently don't seem to care about the rest of them or have already found something equivilent.

You also leave out a lot of information, which makes it really hard to help you. You will need a give some more information on what you are trying to do on some of them if you expect us to answer you in a helpful manner. I have done my best to be helpful where the answer is easy enough to find.


1. InitializeSecurityDescriptor
9. IsValidSecurityDescriptor


Depends on what you want to do with said descriptor. This isn't something that can be answered based on how little information you provide.


2. InterlockedCompareExchange
3. InterlockedDecrement
4. InterlockedExchange
5. InterlockedIncrement


You want the OS APIs that do atomic operations on integers. http://developer.apple.com/documentation/Darwin/Reference/ManPages/man3/atomic.3.html


6. IsBadReadPtr


No, and there is no usefulness in such a method.

Even in Windows, you should avoid using this method:

Important This function is obsolete and should not be used. Despite its name, it does not guarantee that the pointer is valid or that the memory pointed to is safe to use. For more information, see Remarks on this page.



7. IsValidCodePage
8. IsValidLocale
12. LCMapStringW


Encodings are handled fairly differently on OS X than Windows. Instead of assuming you are using wide string arrays like in Win32, OS X wraps up all the encoding nastiness behind CFString and NSString. So converting from one to another is done using the CFString API directly.

http://developer.apple.com/documentation/CoreFoundation/Conceptual/CFStrings/Articles/Converting.html

As for checking if a code page or locale is valid... all code pages supported by the OS are valid. If you want information on the preferred and known locales that the system has, you can use the CFLocale API set.

http://developer.apple.com/documentation/CoreFoundation/Reference/CFLocaleRef/Reference/reference.html


10. IsWindow


This is very specific to what you are trying to do. In Carbon and Cocoa, they have very different handling of windows (as the developer sees them, anyways)... so I can't really give any generic advice here without knowing what the code is trying to do.


11. KillTimer


The API collection you use to create and setup the timer will have a similar API for killing the timer. You will want to use the documentation you (hopefully) looked up on how to create a timer to find out how to tear down the timer you are using.


13. LeaveCriticalSection


You will want a mutex on POSIX systems (like OS X) rather than a critical section. They offer the same behavior. You can do this a few different ways.

NSRecursiveLock (Cocoa): http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSRecursiveLock_Class/Reference/Reference.html

MPEnterCriticalRegion (Carbon): http://developer.apple.com/documentation/Carbon/Conceptual/Multitasking_MultiproServ/03tasks/chapter_3_section_9.html

pthread mutexes (POSIX/Carbon/Cocoa):
http://developer.apple.com/documentation/Darwin/Reference/ManPages/man3/pthread.3.html


14. LoadLibraryExW

This entirely depends on what you expect to do with the library you are attempting to load. For DLLs that your app requires as a framework/library, there isn't really any replacement. Dynamic linking is handled quite differently on OS X in general, and your code will have to adapt.

If you are trying to provide a plugin architecture, the mechanism for doing so is very different. Apple does have guides for this... http://developer.apple.com/documentation/CoreFoundation/Conceptual/CFPlugIns/CFPlugIns.html

prashantmirge
Apr 8, 2008, 03:22 AM
I could able to find for some of API call. but now i want to know is there any equivalent API function in MAC for following windows api-
VarDecFromR8
VarI2FromCy
VarI2FromDec
VarI2FromI1
VarI2FromI4
VarI2FromR4

wrldwzrd89
Apr 8, 2008, 09:12 AM
I could able to find for some of API call. but now i want to know is there any equivalent API function in MAC for following windows api-
VarDecFromR8
VarI2FromCy
VarI2FromDec
VarI2FromI1
VarI2FromI4
VarI2FromR4
My understanding is that these functions are only needed because of the way Windows handles data of type "Variant". Since this type doesn't exist in the Mac APIs (as far as I know, along with the Currency and Decimal types), these functions are not needed. If you need to work with generic data, currency data, or decimals, you can use void pointers, floats and doubles to accomplish this, and type casts to convert between them.

shaggy.mac
Apr 8, 2008, 09:23 AM
Is there Equivalent API in MAC
for the following API's in window.
1. InitializeSecurityDescriptor
2. InterlockedCompareExchange
3. InterlockedDecrement
4. InterlockedExchange
5. InterlockedIncrement
6. IsBadReadPtr
7. IsValidCodePage
8. IsValidLocale
9. IsValidSecurityDescriptor
10. IsWindow
11. KillTimer
12. LCMapStringW
13. LeaveCriticalSection
14. LoadLibraryExW

Based on your two posts, it looks like your job is to convert a Windows app to Mac OS X. If thats the case then please use oDesk.com to hire someone or make the information on the post more clear. Nothing is worse than trying to trick someone into doing your work for you.

Krevnik
Apr 8, 2008, 12:29 PM
Based on your two posts, it looks like your job is to convert a Windows app to Mac OS X. If thats the case then please use oDesk.com to hire someone or make the information on the post more clear. Nothing is worse than trying to trick someone into doing your work for you.

The thing that worries me here is that it looks like a brute-force port, rather than hiring someone who knows both platforms well enough to do a clean port.

It will result in a lot of wasted time an effort, IMO.

yeroen
Apr 8, 2008, 12:40 PM
Not that it bears repeating, but porting an app from Windows --> OSX (or any UNIX variant), is highly non trivial if the Windows APIs were used.
Merely mapping or attempting to map Windows function calls to OS X/POSIX calls on a one-to-one basis will only take you so far. It's much more than a straight port, you're looking at an entire redesign.

sabharwal81
Aug 26, 2009, 04:32 AM
Hi
I am looking for a MAC equivalent of Win control CMFCShellTreeCntrl. Actually i want to draw a control on mac that displays files in any folder as a tree structure, same way as XCode/finder represents files.

kainjow
Aug 26, 2009, 04:45 AM
If you're using Cocoa, it's an NSOutlineView.

gnasher729
Aug 26, 2009, 05:22 AM
Hi
I am looking for a MAC equivalent of Win control CMFCShellTreeCntrl. Actually i want to draw a control on mac that displays files in any folder as a tree structure, same way as XCode/finder represents files.

Instead of joining MacRumors to ask questions that you need for your job, why don't you ask your company to invest in some training? Buy a bunch of Cocoa books, get an Apple developer account, download the training movies, that kind of thing.

Not that it bears repeating, but porting an app from Windows --> OSX (or any UNIX variant), is highly non trivial if the Windows APIs were used.
Merely mapping or attempting to map Windows function calls to OS X/POSIX calls on a one-to-one basis will only take you so far. It's much more than a straight port, you're looking at an entire redesign.

You are missing the point. This kind of job is outsourced, so some manager realizes huge money savings and gets a huge bonus, leaves the company before the **** hits the fan, and then the next guy has to hire some proper Mac developers to fix it or the project dies. The important thing is the bonus for cost savings that gets paid out.