Answered by:
Does metro style App only use Metro style dll's?

Question
-
Hi all,
These days, I am confusing by the question that whether Metro style App can use Win32 dll. From http://social.msdn.microsoft.com/Forums/en-US/winappswithcsharp/thread/1bec1fd8-3f1c-4f84-a2b9-f3e9086dce39, we can add a Win32 dll, if the native module calls only functions available to Metro style apps. However, from item 3.1 of http://msdn.microsoft.com/en-us/library/windows/apps/hh694083, it is forbidden to add any Win32 dlls.
So can Metro style App add some of Win32 dlls compiled by VC6 and use the APIs, or it cannot add any one of them? And can you tell me the scope of functions available to metro style apps? Is it only those listed in http://msdn.microsoft.com/en-us/library/windows/apps/br205757.aspx? You know it is only a subset of Win32 APIs, maybe it is difficult to cover all the requirements I need. Are there any other Win32 APIs I can use? Such as, _tcscmp, _tcscpy, etc.
If I cannot use DllImport to add Win32 dlls compiled by VC6, does that mean I have to create Metro style VC++ dlls and re-write codes with APIs only listed in http://msdn.microsoft.com/en-us/library/windows/apps/br205757.aspx? or other APIs to reference?
For example, in my current metro style APP, I first used VC6 to generate a dll, wrapping the WinSock2.h APIs for TCP/UDP connetcions. Then I add this dll into project and use DllImport to use the API, I found I can use them for broadcasting, and file transfering. However, in http://social.msdn.microsoft.com/Forums/en-US/winappswithcsharp/thread/7ce8adaf-ecba-47be-ac71-040fa75f756d, I was told not to use the API for APP certification in Windows APP Store. I am so confused about whether I can and how I use Win32 APIs existing since VC6. Thanks!
Thursday, March 22, 2012 2:21 AM
Answers
-
Hi Dongjjing,
It looks like you've posted essentially the same question in many places. Please post it only once.
Metro style apps can use Win32 DLLs so long as the DLLs use only API which are available to Metro style apps. Calling API from a DLL counts the same as if you called them from your app itself. While you can bypass the compile-time restrictions intended to help you avoid disallowed API, the app will still fail certification.
See Win32 and COM for Metro style apps for the list of available API. Your app will not pass certification if it tries to use them. See How to test your app with the Windows App Certification Kit for instructions on testing if your app will pass certification locally.
_tcscmp and _tcscpy are part of the C-runtime and are not Win32 API. The WinSock2 API are part of the Win32 Desktop Family and are not available to Metro style apps. If you include them in your DLL then your app won't pass certification. I suspect that the VC6 runtime libraries won't pass certification, but you can test that with the cert kit. It may depend on what in them you call. You may need to recompile the DLL with VS11.
--Rob
- Marked as answer by Rob Caplan [MSFT]Microsoft employee, Moderator Thursday, March 22, 2012 2:47 AM
Thursday, March 22, 2012 2:47 AMModerator
All replies
-
Hi Dongjjing,
It looks like you've posted essentially the same question in many places. Please post it only once.
Metro style apps can use Win32 DLLs so long as the DLLs use only API which are available to Metro style apps. Calling API from a DLL counts the same as if you called them from your app itself. While you can bypass the compile-time restrictions intended to help you avoid disallowed API, the app will still fail certification.
See Win32 and COM for Metro style apps for the list of available API. Your app will not pass certification if it tries to use them. See How to test your app with the Windows App Certification Kit for instructions on testing if your app will pass certification locally.
_tcscmp and _tcscpy are part of the C-runtime and are not Win32 API. The WinSock2 API are part of the Win32 Desktop Family and are not available to Metro style apps. If you include them in your DLL then your app won't pass certification. I suspect that the VC6 runtime libraries won't pass certification, but you can test that with the cert kit. It may depend on what in them you call. You may need to recompile the DLL with VS11.
--Rob
- Marked as answer by Rob Caplan [MSFT]Microsoft employee, Moderator Thursday, March 22, 2012 2:47 AM
Thursday, March 22, 2012 2:47 AMModerator -
First, Welcome to Metro style app development.
Regarding your understanding of section 3.1 http://msdn.microsoft.com/en-us/library/windows/apps/hh694083 you have reached the wrong conclusion. The message that section is trying to deliver is if you have a component (in your case a Win32 DLL) that only uses the Windows provided API's available to Metro style apps then it can be included in your app. Every component you include in your Metro style app must limit their use to the Windows API's in this list: API reference for Metro style apps
As Rob mentioned in your other post, it is unlikely your VS6 compiled component will pass certification as it likely has dependencies on runtimes that will not pass certification.
Compiling it in VS11 is a good first step. You might take a look at this thread for some insight from persons that have been down this path previously:
This list may also be helpful to you while learning what alternatives are available for API's you previously used: Alternatives to Windows APIs in Metro style apps
I hope this helps make the transition a bit cleared for you.
Thanks!
David Lamb
- Edited by DavidLambMicrosoft employee, Moderator Thursday, March 22, 2012 3:15 AM
Thursday, March 22, 2012 3:07 AMModerator