473,395 Members | 1,527 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How could I get return handle from DllImport?

Hi,

I used LoadLibrary in C++. Now I changed it to C#.
C++ codes:
hKernelLib = LoadLibrary("kernel32.dll");
C# codes:
[DllImport("kernel32.dll")]

The problem is I need hKernelLib (which is the value returned from invoking
LoadLibrary), and it will be a parameter for the next API (such as
GetProcAddress).
How could I get this return value from DllImport?

Thanks
Nov 16 '05 #1
1 2662
static extern IntPtr LoadLibrary(...)

Willy.

"Sherry" <sh****@metaquest.com> wrote in message
news:et**************@TK2MSFTNGP10.phx.gbl...
Hi,

I used LoadLibrary in C++. Now I changed it to C#.
C++ codes:
hKernelLib = LoadLibrary("kernel32.dll");
C# codes:
[DllImport("kernel32.dll")]

The problem is I need hKernelLib (which is the value returned from
invoking
LoadLibrary), and it will be a parameter for the next API (such as
GetProcAddress).
How could I get this return value from DllImport?

Thanks

Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Fred Hebert | last post by:
I am trying to use a 3rd party DLL that requires the main window handle as a parameter. e.g. MyFunc(WHND MyHandle); The example looks something like this: Result = MyFunc(Handle); Where...
9
by: Angel | last post by:
Hi again, I'm trying to call functions from a proprietary DLL but it's turned out to be more difficult than I thought. I have this W32.DLL which was written in C by USPS. They don't provide the...
11
by: objectref | last post by:
Hi to all, is there a way to get the window handle of the main window of an application or process ? For example, if someone opens Microsoft Word, he gets a window so he/she can write text....
6
by: Wes | last post by:
Hello, I am writing a class in C# that uses to call functions from a C++ dll. Evenything seems to work fine call the functions except one of the functions takes a *File as a parameter. Many...
10
by: Mark Jerde | last post by:
I'm trying to learn the very basics of using an unmanaged C++ DLL from C#. This morning I thought I was getting somewhere, successfully getting back the correct answers to a C++ " int SumArray(int...
5
by: Jason W | last post by:
I have a C# class that I wan't to be able to use in VB6 and VBA applications. To do this I was trying to use a mixed managed VC++ dll and export a function. Doing this I get an error "The memory...
13
by: Abhishek | last post by:
Hi, how do I pass the handle of a control to the win32 api mouse_event. so that it will create the click event on that application only even if there is any other window in front of it. I dont...
1
by: Sanghoon Lee | last post by:
I wrote tiny sample of smart client using Win32 API and get parent IE's handle as follow public static extern IntPtr GetParent(IntPtr hWnd); IntPtr cHandle = this.Handle; // this is smart...
2
by: =?Utf-8?B?QWxleCBLLg==?= | last post by:
Hi all My TreeView has unicode and english labels. The treeview shows OK on the screen. When I am trying to get an item's label using TVM_GETITEM API message, the buffer returned by SendMessage...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.