473,385 Members | 1,317 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,385 software developers and data experts.

Help PLease

Hello Folks,
Newbie here needs a little help.
Here is my issue.
I want to place all my dll import data into class called testdllimport.cs
Then I want to call, reference, or instantiate the class in my form1.cs!!
Is this possible.

Thanks in advance.
Nov 17 '05 #1
4 1960
DLLImport statements are all static extern anyway so just go ahead and do
what you suggest.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"Dmension" <df****@napcosecurity.com> wrote in message
news:eB**************@TK2MSFTNGP15.phx.gbl...
Hello Folks,
Newbie here needs a little help.
Here is my issue.
I want to place all my dll import data into class called testdllimport.cs
Then I want to call, reference, or instantiate the class in my form1.cs!!
Is this possible.

Thanks in advance.

Nov 17 '05 #2
Thanks for the reply Bob,
But my issue is, I dont know how to instantiate that class I created in
my form1.cs and where should I do this. If possible could you give me a
small piece of code to get me started. I already placed the dll imports in a
class.

"Bob Powell [MVP]" <bob@_spamkiller_bobpowell.net> wrote in message
news:O1**************@TK2MSFTNGP10.phx.gbl...
DLLImport statements are all static extern anyway so just go ahead and do
what you suggest.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"Dmension" <df****@napcosecurity.com> wrote in message
news:eB**************@TK2MSFTNGP15.phx.gbl...
Hello Folks,
Newbie here needs a little help.
Here is my issue.
I want to place all my dll import data into class called testdllimport.cs
Then I want to call, reference, or instantiate the class in my form1.cs!!
Is this possible.

Thanks in advance.


Nov 17 '05 #3
you haven't to instatniate th class at all, since the methods are static.

class Inports
{
[DllImport("user32.dll", EntryPoint = ............]
public static extern int SomeImportedFunction(.........);
}

class MyClass
{
int MyMethod()
{
.....
int x = Imports.SomeImportFunction(.......);
.......
}
}

That's all.

"Dmension" <df****@napcosecurity.com> schrieb im Newsbeitrag
news:OF**************@TK2MSFTNGP14.phx.gbl...
Thanks for the reply Bob,
But my issue is, I dont know how to instantiate that class I created in
my form1.cs and where should I do this. If possible could you give me a
small piece of code to get me started. I already placed the dll imports in
a class.

"Bob Powell [MVP]" <bob@_spamkiller_bobpowell.net> wrote in message
news:O1**************@TK2MSFTNGP10.phx.gbl...
DLLImport statements are all static extern anyway so just go ahead and do
what you suggest.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"Dmension" <df****@napcosecurity.com> wrote in message
news:eB**************@TK2MSFTNGP15.phx.gbl...
Hello Folks,
Newbie here needs a little help.
Here is my issue.
I want to place all my dll import data into class called
testdllimport.cs
Then I want to call, reference, or instantiate the class in my
form1.cs!!
Is this possible.

Thanks in advance.



Nov 17 '05 #4
Methods that are static do not require an instance of a class. Look at the
Math class for example. It's methods are all static and can be callled using
Math.Atan2(...) etc.

When you create your class as a placeholder for your interop imports you can
just invoke them using the name of the class followed by the method. For
example...

class MyNativeMethods
{
[DllImport(""user32.dll")]
public static extern IntPtr GetDC(intPtr hWnd);

}

// in your code....

IntPtr hDC=MyNativeMethods.GetDC(this.hWnd);

Hope this helps.
--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"Dmension" <df****@napcosecurity.com> wrote in message
news:OF**************@TK2MSFTNGP14.phx.gbl...
Thanks for the reply Bob,
But my issue is, I dont know how to instantiate that class I created in
my form1.cs and where should I do this. If possible could you give me a
small piece of code to get me started. I already placed the dll imports in
a class.

"Bob Powell [MVP]" <bob@_spamkiller_bobpowell.net> wrote in message
news:O1**************@TK2MSFTNGP10.phx.gbl...
DLLImport statements are all static extern anyway so just go ahead and do
what you suggest.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"Dmension" <df****@napcosecurity.com> wrote in message
news:eB**************@TK2MSFTNGP15.phx.gbl...
Hello Folks,
Newbie here needs a little help.
Here is my issue.
I want to place all my dll import data into class called
testdllimport.cs
Then I want to call, reference, or instantiate the class in my
form1.cs!!
Is this possible.

Thanks in advance.



Nov 17 '05 #5

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

Similar topics

3
by: laurie | last post by:
Hi all, I'm trying to help out a friend who has inherited a client with a PHP shopping cart application. Neither of us know PHP, but I've been muddling my way through, trying to get these old...
1
by: the_proud_family | last post by:
HELP ME PLEASE!! my email is the_proud_family@yahoo.com I can't get the ball to go up right side and then I need it to turn around and keep turning until velocity=0 I have been at it for the ...
0
by: Kurt Watson | last post by:
I’m having a different kind of problem with Hotmail when I sign in it says, "Web Browser Software Limitations Your Current Software Will Limit Your Ability to Use Hotmail You are using a web...
12
by: Christo | last post by:
borland c++ 5.01 character constant must be one or two characters long get this when compiling my first c++ program can anyone out there help? it is highlighting this line as the problem ...
7
by: x muzuo | last post by:
Hi guys, I have got a prob of javascript form validation which just doesnt work with my ASP code. Can any one help me out please. Here is the code: {////<<head> <title>IIBO Submit Page</title>...
5
by: Craig Keightley | last post by:
Please help, i have attached my page which worksin IE but i cannnot get the drop down menu to fucntion in firefox. Any one have any ideas why? Many Thanks Craig ...
17
by: JT | last post by:
Help me the following C++ question: Write a program to help a local bookshop automate its billing system. The program should do the following: (a)Let the user enter the ISBN, the system will...
7
by: tyler_durden | last post by:
thanks a lot for all your help..I'm really appreciated... with all the help I've been getting in forums I've been able to continue my program and it's almost done, but I'm having a big problem that...
23
by: Jason | last post by:
Hi, I was wondering if any could point me to an example or give me ideas on how to dynamically create a form based on a database table? So, I would have a table designed to tell my application...
2
by: =?Utf-8?B?U2NvdHRSYWREZXY=?= | last post by:
I'm creating a doc project for my c# program. I've done this before but this time sonething is wrong. I build my doc project and is succeeds but when I open the help file, there is no documentation...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.