locked
Using a C DLL in a Store App in VB.NEt RRS feed

  • Question

  • I am trying to write a Store App in VB.NET use an API from a C DLL that is installed as part of a driver package and exists in the SYSTEM32 folder.   I am trying to duplicate functionality of a utility that was written in VB6 and works fine in Windows 8.   When I call the API functions they are returning internal errors.  There doesn't seem to be any problem with my function definition or the Store App code (no exceptions are raised) but the DLL API functions are not working.  This same declare function works in the VB6 code just fine.   

    Can it be that the C DLL behaves different when called within the Store App than in the VB6 Windows Forms EXE?

    I do not want to include the DLL in the project as it is part of the system and don't want to duplicate the DLL.  

    I am using the syntax  

    Declare Function  apifunctioname Lib "APIDLL.DLL" () as Integer

    Like I said I don't seem to be having any trouble with the Store App code and referencing the API functions.  But all the API calls are failing when run in the Store App?

    Any Suggestions?



    Jeff Davis

    Friday, November 9, 2012 9:06 PM

Answers

  • Windows Store apps don't have access to the registry, so you cannot use this DLL from one. DLLs used in Windows Store apps can call only the set of functions allowed for Windows Store apps. See Win32 and COM APIs for a list of the allowed API.

    Since it sounds like the goal of the DLL is to modify settings that are not available to Windows Store apps you would need to write your interface to it as a desktop app.

    --Rob

    • Marked as answer by Aaron Xue Friday, November 23, 2012 11:48 AM
    Thursday, November 15, 2012 2:48 AM
    Moderator

All replies

  • Windows Store apps run with limited privileges and can only call specific API.

    It would help if you could provide more information about the errors that you are getting, but it is likely that the problem is that the DLL requires permissions that Windows Store apps do not have.

    --Rob

    • Marked as answer by Aaron Xue Friday, November 23, 2012 11:47 AM
    • Unmarked as answer by Aaron Xue Friday, November 23, 2012 11:48 AM
    Friday, November 9, 2012 9:12 PM
    Moderator
  • The C DLL reads and writes to the registry as its way of communicating to a custom System Effects Audio Processing Object (APO).  It in effect wraps the APO API into its own set of how level functions to manipulate the custom Audio Effects.   The Store App (windows 8 metro app)  is just a user interface that allows the user to change some values.   In Vista and Windows 7 this was done in a tool tray application written by the 3rd party APO developer and packaged with the Audio Driver.   In Windows 8 we would like to make this GUI be a metro style application.  The errors returned from the API DLL are normal errors that occur when the DLL fails internally.   Our guess is because its calls to read or write to the registry are failing because of lack of permission from the calling program.   

    How are Metro Style apps supposed to deal with 3rd party DLL's that normally are used in GUI applications written by 3rd parties?


    Jeff Davis

    Thursday, November 15, 2012 12:20 AM
  • Windows Store apps don't have access to the registry, so you cannot use this DLL from one. DLLs used in Windows Store apps can call only the set of functions allowed for Windows Store apps. See Win32 and COM APIs for a list of the allowed API.

    Since it sounds like the goal of the DLL is to modify settings that are not available to Windows Store apps you would need to write your interface to it as a desktop app.

    --Rob

    • Marked as answer by Aaron Xue Friday, November 23, 2012 11:48 AM
    Thursday, November 15, 2012 2:48 AM
    Moderator
  • I have read that one solution to this problem is to write a .NET local web service that wraps the DLL calls and exposes them.   The store app can then access the web service to make the calls.  Is this possible in my case and how is that done or could you point me to some examples of using a web service in a Metro Style App?


    Jeff Davis

    Saturday, November 17, 2012 4:45 PM
  • no its not possibe.

    first how you going to deploy this? the webservice have to run in the desktop (service / desktop app / iis)

    and the second problem is that metro apps cant connect to localhost (only in development envoriment this works)


    Microsoft Certified Solutions Developer - Windows Store Apps Using C#

    Saturday, November 17, 2012 4:52 PM
  • I was assuming I could install the Webservice as part of the driver install.  But if the metro app can't connect to a local webservice then I guess it doesn't matter.

    So what I am finding out is that there isn't a way to wrap my Win32 DLL so that the metro app can communicate with it.

    My original intent was to be able to have a more native Windows 8 application that didn't run on the desktop from the tooltray like we do in Vista/Windows 7.   I wanted to have a native charm with splash screen and use XAML GUI that used the metro style user interface including touch screen support etc within the UI.  Is there another type of project in Visual Studio 2012 that will produce the same thing that is not a Store App?

    If not then how do I get the Store App to access this API within the win32 C DLL if a local Webservice won't work?  Can I wrap the DLL in a traditional windows service and can that be accessed by the metro app?  Is there another way that is better?

     


    Jeff Davis

    Saturday, November 17, 2012 7:15 PM
  • Could you use direct x instead of your dll?
    Saturday, November 17, 2012 7:30 PM
  • no not really good solution for you.. get rid of the dll (rebuild so its compatible?) or a desktop app

    Microsoft Certified Solutions Developer - Windows Store Apps Using C#

    Saturday, November 17, 2012 7:37 PM
  • Hi Jeff,

    I'm not quite sure if I understand what you are looking for here. Are you trying to write a UI for your own device? Take a look at Windows Store device apps to see if that meets your needs.

    If not then you will need to write your app as a desktop app. There is no way for a driver to provide new API to arbitrary Windows Store apps.

    Desktop apps can (and should) support touch screens. You can use WPF or Silverlight to write a desktop app with Xaml, although you'll have a slightly different set of base controls to work with.

    --Rob

    Saturday, November 17, 2012 8:01 PM
    Moderator
  • No DirectX doesn't help.

    3rd Party Audio special effects providers usually work with the  Audio Driver Vendor to integrate their extra features.   These are done as an APO and exposed through an API that then GUI developers can use to add to their audio projects (ie a checkbox for enabling a Deep Bass feature or a radio button to select Hall, Theater, Livinging room presets).  Often but not always these features are integrated into a control panel tab.   Normally a GUI is available from the tooltray that allows for special audio settings.  These audio settings are also available as a plugin in audio players too.

    I was trying to create a GUI that looked like a native Windows 8 Metro style app using the App Store template.   It would probably eventually be a media player but with extra controls that connected to the special effects that are exposed in the APO API DLL.  

    Whatever is needed to update these API functions would be installed as part of the Audio driver package.  You could then grab the Store App and set the special effects up the way you want.  

    I like what you get with the Store App template and it would make it easy to write a GUI that works in Windows 8.  Having to simulate that with a standard desktop App is going to be too much work.  It will probably be easier to just use the same Vista/Windows 7 GUI design as a desktop app in that case.  

    I have to say I am very disappointed in the lack of options for the GUI I want to create in Windows 8.  


    Jeff Davis

    Sunday, November 18, 2012 2:21 AM