Click here to Skip to main content
15,891,473 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi guys!
I want to export some functions from winmm.lib library ...I tried to use
[DllImport] but it only works for dynamic libraries like kernel32.dll,
wininet32.dll
Posted
Updated 13-Jul-17 19:29pm

Oh, no, this is impossible. You can only P/Invoke a DLL, more exactly, using PE (Portable Executable) file you can link the functions exported.

I think you simply need to use WINMM.DLL instead.

If the LIB file is not link library for any DLL or you don't know what DLL you should use, this is a different story.
To find out, you can use I some binary dump utility such as dumpbin.exe, http://msdn.microsoft.com/en-us/library/c1h23y6c(v=vs.71).aspx[^] (to use this utility, it's best to start from "Visual Studio Command Prompt"). If this is a link library for some DLL, you can find out what DLL file to use. If it is not, you have nothing to P/Invoke.

You should first create some library which you could use in your C# project. Here is what you can do in this case:

Method #1. Create mixed mode project (managed + unmanaged) C++ with C++/CLI. You can link the library as unmanaged code, wrap calls to unmanaged code in C++/CLI class (classes). After that, you can use resulting library like a regular .NET Assembly and reference it in any C# project.

Method #2. Another opportunity is using P/Invoke. In this case, you create a regular unmanaged DLL using C++, link the library and export the function you need. Use P/Invoke with resulting DLL.

—SA
 
Share this answer
 
v7
Comments
#realJSOP 25-Mar-11 22:44pm    
Proposed as answer
Sergey Alexandrovich Kryukov 25-Mar-11 23:02pm    
Thank you, John.
--SA
Sandeep Mewara 26-Mar-11 3:09am    
My 5++ (Already proposed as an answer!)
Sergey Alexandrovich Kryukov 26-Mar-11 14:22pm    
Thank you, Sandeep.
--SA
errdggdfgdfgdfgfgdfgdgdfgdfggdfgdfgdfgdfg
 
Share this answer
 
Comments
Richard Deeming 14-Jul-17 10:09am    
Remove this non-answer, or you risk being banned from the site.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900