locked
Accessing Win32 API from WinRT through a Win32 Dll

    Question

  • Hi, I am trying to call Win32 API from Windows Store App. Since Win32 APIs can not be accessed from WinRT, I have written a Win32 Dll and exposed a function.

    I am trying to call this function from WinRT App. But I am getting 'Access Denied' Error.

    Dll Code:

    extern "C" __declspec( dllexport )INT32 ScanWlan()
    {
    // Declare and initialize variables.
    
    HANDLE hClient = NULL;
    DWORD dwError = ERROR_SUCCESS;
    
    DWORD dwMaxClient = 2;  
    DWORD dwCurVersion = 0;
    DWORD dwResult = 0;
    
    dwResult = WlanOpenHandle(dwMaxClient, NULL, &dwCurVersion, &hClient);
    if (dwResult != ERROR_SUCCESS) 
    {
    WlanCloseHandle(hClient, NULL);
    wprintf(L"WlanOpenHandle failed with error: %u\n", dwResult);
    return 1;
    }

    I am able to call this funtion from WinRT App. But 'WlanOpenHandle' function failed with error 5 (ERROR_ACCESS_DENIED).

    I have done this using administrator login also. But still I am getting the same error.

    Am I doing the right thing?

    Can We access Win32 APIs from WinRT Apps through Dlls (at least).

    Any help?

    Thank you,

    Sai

    Monday, April 1, 2013 2:16 PM

Answers

  • Can We access Win32 APIs from WinRT Apps through Dlls (at least).

    Windows Store app runs in a sandboxed envirnoments which limits your application's access to Win32 APIs.

    In addition, if a Windows Store app calls any not supported API, it will not pass the Windows Store certification.

    You can see the list of the supported API here.

    Best regards,


    Min Zhu
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Aaron Xue Monday, April 8, 2013 7:31 AM
    Tuesday, April 2, 2013 3:12 AM
    Moderator
  • There are no equivalent APIs to get these information directly in Windows Runtime.

    Robin [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Aaron Xue Monday, April 8, 2013 7:31 AM
    Friday, April 5, 2013 6:41 AM
    Moderator

All replies

  • Can We access Win32 APIs from WinRT Apps through Dlls (at least).

    Windows Store app runs in a sandboxed envirnoments which limits your application's access to Win32 APIs.

    In addition, if a Windows Store app calls any not supported API, it will not pass the Windows Store certification.

    You can see the list of the supported API here.

    Best regards,


    Min Zhu
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Aaron Xue Monday, April 8, 2013 7:31 AM
    Tuesday, April 2, 2013 3:12 AM
    Moderator
  • Hi Min Zhu, thanks for your reply.

    I want to know are there any APIs available in WinRT to

    1) Find WLAN interaface list (Win32 API - WlanEnumInterfaces)

    2) Find Wi-Fi access points (Win32 API - WlanGetAvailableNetworkList)

    Basically I am trying to write an WinRT application to do all these.

    Any help?

    Regards,

    Sai


    • Edited by SaiMm Tuesday, April 2, 2013 11:01 AM
    Tuesday, April 2, 2013 11:00 AM
  • There are no equivalent APIs to get these information directly in Windows Runtime.

    Robin [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Aaron Xue Monday, April 8, 2013 7:31 AM
    Friday, April 5, 2013 6:41 AM
    Moderator