Question about DllImport
-
Hello, I'm posting what I hope will not be too ignorant of a question regarding com interop :-) A number of times I've seen in examples on this site a piece of code where the author has used com interop to call a method from an external dll (I assume c++ dlls being called from the c# code). My question is if you did not author the c++ dll yourself what is the best method to find out what the classes, methods, etc are that are contained in the dll? Basically, where do you determine what it is that you need to call from the dll? For example, consider this call to an external dll (from an article here on Code Project): private static extern long WritePrivateProfileString(string section, string key, string val, string filePath); How did the author determine that in the dll that he called that there is a WritePrivateProfileString method and that it takes 4 string parameters? Is there some utility out there that allows you to browse c++ dlls and that you can use to determine what method and parameters you would need to import? Bear in mind that I'm still learning c# and com interop is one subject that I've struggled to understand fully. Thanks.
-
Hello, I'm posting what I hope will not be too ignorant of a question regarding com interop :-) A number of times I've seen in examples on this site a piece of code where the author has used com interop to call a method from an external dll (I assume c++ dlls being called from the c# code). My question is if you did not author the c++ dll yourself what is the best method to find out what the classes, methods, etc are that are contained in the dll? Basically, where do you determine what it is that you need to call from the dll? For example, consider this call to an external dll (from an article here on Code Project): private static extern long WritePrivateProfileString(string section, string key, string val, string filePath); How did the author determine that in the dll that he called that there is a WritePrivateProfileString method and that it takes 4 string parameters? Is there some utility out there that allows you to browse c++ dlls and that you can use to determine what method and parameters you would need to import? Bear in mind that I'm still learning c# and com interop is one subject that I've struggled to understand fully. Thanks.
The DLL has to be documented. That means, the signatures of the functions are described in a text file. MSDN contains a bit of documentation for all Win32 DLLs. If a DLL has no documentation, you're not supposed to use it. ;) Look, there are the MSDN pages for WritePrivateProfileString and the whole platform SDK. _________________________________ Please inform me about my English mistakes, as I'm still trying to learn your language! -- modified at 17:10 Friday 14th April, 2006
-
The DLL has to be documented. That means, the signatures of the functions are described in a text file. MSDN contains a bit of documentation for all Win32 DLLs. If a DLL has no documentation, you're not supposed to use it. ;) Look, there are the MSDN pages for WritePrivateProfileString and the whole platform SDK. _________________________________ Please inform me about my English mistakes, as I'm still trying to learn your language! -- modified at 17:10 Friday 14th April, 2006