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

Windows API calls in .NET application

Dear All,
I'm new to .NET and it seems that I'm terribly confused. I'm used to
program windows applications using C++ and native API. I decided to try
..NET windows Form application. Of course, Visual Studio did everything for
me and some empty form showed up on the screen upon starting the
application.

Then I incorporated really hardcore API calls such as RegisterClass and
CreateWindow and implemented wndProc, like in old days. What happened:
another window showed up and behaved as I would expect. Now, how does it
fit together with the idea of the intermediate language and runtime and all
that stuff that is written about the .NET? I was thinking that either the
project would not compile, or it would crash upon startup, but it seems like
you can stick your API code just fine. Am I missing something here?

Tons of thanks,
Alex.
Nov 10 '05 #1
5 1746
CT
C++ is generally unmanaged code more or less like you're used to, but you
can use managed extensions to get the benefits of managed code, i.e. code
that is executed/managed by the CLR of the .NET Framework. Here's a brief
overview with a number of articles that might be of interest to you.

--
Carsten Thomsen
Communities - http://community.integratedsolutions.dk
---------
Voodoo Programming: Things programmers do that they know shouldn't work but
they try anyway, and which sometimes actually work, such as recompiling
everything. (Karl Lehenbauer)
---------
"Karlsson-on-the-roof" <po****@u.washington.edu> wrote in message
news:dk**********@gnus01.u.washington.edu...
Dear All,
I'm new to .NET and it seems that I'm terribly confused. I'm used to
program windows applications using C++ and native API. I decided to try
.NET windows Form application. Of course, Visual Studio did everything
for me and some empty form showed up on the screen upon starting the
application.

Then I incorporated really hardcore API calls such as RegisterClass and
CreateWindow and implemented wndProc, like in old days. What happened:
another window showed up and behaved as I would expect. Now, how does it
fit together with the idea of the intermediate language and runtime and
all that stuff that is written about the .NET? I was thinking that either
the project would not compile, or it would crash upon startup, but it
seems like you can stick your API code just fine. Am I missing something
here?

Tons of thanks,
Alex.

Nov 10 '05 #2

"Karlsson-on-the-roof" <po****@u.washington.edu> wrote in message
news:dk**********@gnus01.u.washington.edu...
Dear All,
I'm new to .NET and it seems that I'm terribly confused. I'm used to
program windows applications using C++ and native API. I decided to try
.NET windows Form application. Of course, Visual Studio did everything
for me and some empty form showed up on the screen upon starting the
application.

Then I incorporated really hardcore API calls such as RegisterClass and
CreateWindow and implemented wndProc, like in old days. What happened:
another window showed up and behaved as I would expect. Now, how does it
fit together with the idea of the intermediate language and runtime and
all that stuff that is written about the .NET? I was thinking that either
the project would not compile, or it would crash upon startup, but it
seems like you can stick your API code just fine. Am I missing something
here?


You are completely free to use platform APIs, that is much of hte point of
having the managed C++ language(which I assume you are using) and the entire
platform invoke subsystem.

The intermediate language and runtime offer non-API methods of doing a great
deal, including creating windows, but it does not preclude the use of the
APIs. There are limitations, of course, portability drops and there might be
security or stability issues that wouldn't be there in fully managed code,
but the runtime was designed to allow interop.
Nov 10 '05 #3
CT
....and this is the brief overview I mentioned...
http://www.gotdotnet.com/team/cplusplus/

--
Carsten Thomsen
Communities - http://community.integratedsolutions.dk
---------
Voodoo Programming: Things programmers do that they know shouldn't work but
they try anyway, and which sometimes actually work, such as recompiling
everything. (Karl Lehenbauer)
---------
"CT" <ca******@spammersgoawayintegrasol.dk> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
C++ is generally unmanaged code more or less like you're used to, but you
can use managed extensions to get the benefits of managed code, i.e. code
that is executed/managed by the CLR of the .NET Framework. Here's a brief
overview with a number of articles that might be of interest to you.

--
Carsten Thomsen
Communities - http://community.integratedsolutions.dk
---------
Voodoo Programming: Things programmers do that they know shouldn't work
but they try anyway, and which sometimes actually work, such as
recompiling everything. (Karl Lehenbauer)
---------
"Karlsson-on-the-roof" <po****@u.washington.edu> wrote in message
news:dk**********@gnus01.u.washington.edu...
Dear All,
I'm new to .NET and it seems that I'm terribly confused. I'm used to
program windows applications using C++ and native API. I decided to try
.NET windows Form application. Of course, Visual Studio did everything
for me and some empty form showed up on the screen upon starting the
application.

Then I incorporated really hardcore API calls such as RegisterClass and
CreateWindow and implemented wndProc, like in old days. What happened:
another window showed up and behaved as I would expect. Now, how does it
fit together with the idea of the intermediate language and runtime and
all that stuff that is written about the .NET? I was thinking that
either the project would not compile, or it would crash upon startup, but
it seems like you can stick your API code just fine. Am I missing
something here?

Tons of thanks,
Alex.


Nov 10 '05 #4
Thanks for replies and links to read. Well, things began to clarify a
little bit. Still a question: was my code converted to the intermediate
language or not? In the debugger I was able to see assembly code that
looked like I would expect if I had just a normal API application. I read
something about JIT compilation, and perhaps I saw the assembbly code after
JIT compilation, but still, I'm not sure.

Thanks for any help.
Alex.
"Daniel O'Connell [C# MVP]" <onyxkirx@--NOSPAM--comcast.net> wrote in
message news:eG**************@TK2MSFTNGP11.phx.gbl...

"Karlsson-on-the-roof" <po****@u.washington.edu> wrote in message
news:dk**********@gnus01.u.washington.edu...
Dear All,
I'm new to .NET and it seems that I'm terribly confused. I'm used to
program windows applications using C++ and native API. I decided to try
.NET windows Form application. Of course, Visual Studio did everything
for me and some empty form showed up on the screen upon starting the
application.

Then I incorporated really hardcore API calls such as RegisterClass and
CreateWindow and implemented wndProc, like in old days. What happened:
another window showed up and behaved as I would expect. Now, how does it fit together with the idea of the intermediate language and runtime and
all that stuff that is written about the .NET? I was thinking that either the project would not compile, or it would crash upon startup, but it
seems like you can stick your API code just fine. Am I missing something here?

You are completely free to use platform APIs, that is much of hte point of
having the managed C++ language(which I assume you are using) and the

entire platform invoke subsystem.

The intermediate language and runtime offer non-API methods of doing a great deal, including creating windows, but it does not preclude the use of the
APIs. There are limitations, of course, portability drops and there might be security or stability issues that wouldn't be there in fully managed code,
but the runtime was designed to allow interop.

Nov 10 '05 #5

"Karlsson-on-the-Roof" <po****@u.washington.edu> wrote in message
news:dk**********@gnus01.u.washington.edu...
Thanks for replies and links to read. Well, things began to clarify a
little bit. Still a question: was my code converted to the intermediate
language or not? In the debugger I was able to see assembly code that
looked like I would expect if I had just a normal API application. I read
something about JIT compilation, and perhaps I saw the assembbly code
after
JIT compilation, but still, I'm not sure.

Well, thats tough to say for sure without knowing what version of the
compiler you were using and what options were specified. Open the executable
in ildasm or reflector[1] to see.

The C++ compiler is capable of generating a mixture of languages. Part of
your code certainly was IL, and some was probably native, but its possible
it was all native, depending on options and the like.

1. http://www.aisto.com/roeder/dotnet/ Thanks for any help.
Alex.
"Daniel O'Connell [C# MVP]" <onyxkirx@--NOSPAM--comcast.net> wrote in
message news:eG**************@TK2MSFTNGP11.phx.gbl...

"Karlsson-on-the-roof" <po****@u.washington.edu> wrote in message
news:dk**********@gnus01.u.washington.edu...
> Dear All,
> I'm new to .NET and it seems that I'm terribly confused. I'm used to
> program windows applications using C++ and native API. I decided to
> try
> .NET windows Form application. Of course, Visual Studio did everything
> for me and some empty form showed up on the screen upon starting the
> application.
>
> Then I incorporated really hardcore API calls such as RegisterClass and
> CreateWindow and implemented wndProc, like in old days. What happened:
> another window showed up and behaved as I would expect. Now, how does it > fit together with the idea of the intermediate language and runtime and
> all that stuff that is written about the .NET? I was thinking that either > the project would not compile, or it would crash upon startup, but it
> seems like you can stick your API code just fine. Am I missing something > here?
>


You are completely free to use platform APIs, that is much of hte point
of
having the managed C++ language(which I assume you are using) and the

entire
platform invoke subsystem.

The intermediate language and runtime offer non-API methods of doing a

great
deal, including creating windows, but it does not preclude the use of the
APIs. There are limitations, of course, portability drops and there might

be
security or stability issues that wouldn't be there in fully managed
code,
but the runtime was designed to allow interop.


Nov 10 '05 #6

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

Similar topics

11
by: Wolfgang Kaml | last post by:
Hello All, I have been working on this for almost a week now and I haven't anything up my sleeves anymore that I could test in addition or change.... Since I am not sure, if this is a Windows...
2
by: Juan Manuel Alegra B. | last post by:
Hi group I have been making a windows service to execute an external application. I use a timer control, I can execute the application but does't appear as a normal windows, just I see it in the...
2
by: David | last post by:
Hello, I have an application that has been running for years and had little problem with it. We've been retesting the latest code under Windows 2003 and found a surprise. There is a certain...
1
by: jerry.xuddd | last post by:
Hello, It should be very simple, but I just can not find out how to do it. I am developing an info share application. The requirement is that everyone can view the information, but can only...
3
by: Brian Keating EI9FXB | last post by:
Hello again, I've already placed a few posts on this topic. This time i've a simple application that exhibits my problem, I've placed sample solution 8k on my website should anyone be interested...
9
by: Justin Engelman | last post by:
Hi, I have a website that uses an ISAPI filter that will redirect anyone going to any page on the site to an SSL login page (on a different website with the same root domain) if they do not have...
2
by: shapper | last post by:
Hello, I usually develop Asp.Net 2.0 (With VB.NET or C#) web sites with SQL 2005 databases. A few of my web sites use online CMS with AJAX. I need to create a Windows Vista compatible...
2
by: =?Utf-8?B?dmlzaHJ1dGg=?= | last post by:
Hi, I have 2 applications running, one Windows application project and the other windows services project. I want to call my Windows application in my windows services. I want to run them as...
7
by: =?Utf-8?B?QmlsbHkgWmhhbmc=?= | last post by:
我们现在遇到一个问题,通过wcf创建的webservice,选择windows service作为宿主,采用java作为客户端调用成功,但是无法使用asp.net ajax调用。...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Shllpp 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.