Solved

Winsock control and formless (windowless) applications

Posted on 1998-02-08
7
478 Views
Last Modified: 2013-11-13
I'm trying to use the Winsock control in an application that has no forms (windows). My goal here is to be able to write server applications that load no windows into memory. Code samples and explanations would be helpful. Thanks.
--
Matt Nicholson
mnichols@cs.fit.edu
0
Comment
Question by:mnichols
  • 4
  • 3
7 Comments
 
LVL 8

Expert Comment

by:mrmick
ID: 1456473
Matt, I assume you're writing a service that doesn't have a stdout or stdin.  To accomplish this you still must use a form, just don't show it.

What's the status on the Controlling Dos Window question?

0
 
LVL 1

Author Comment

by:mnichols
ID: 1456474
Actually this project has nothing to do with controlling DOS windows. And being this is a Visual Basic project, there isn't such a thing as stdin or stdout. I've experimented with the WithEvents keyword when creating a Winsock control, and it appears to turn it into an object, but I can't quite get it to work. Also, I can't use the New keyword to create a new instance of the control, which I think is the key to getting it to work. Dropping a control on a window that has no visual inputs and is never shown is quite silly-- wastes memory. Besides, I'm trying to write an Active DLL, which isn't supposed to have forms anyways. I'm sure there's a way to do it, so I'm leaving the question open.

The DOS window controlling problem is still in the back of my head somewhere. I really want to accomplish it in Visual Basic so it's still up in the air if anyone wants to answer it.
--
Matt Nicholson
mnichols@cs.fit.edu
0
 
LVL 8

Accepted Solution

by:
mrmick earned 100 total points
ID: 1456475
Matt, by design, ActiveX controls MUST be placed on a from.

What I meant by no stdin and stdout is that when you install an app as a service on an NT machine, the app can either be interactive (have a console, read keyboard input etc) or have network access - but not both at the same time.  A service is usually written to survive even if nobody is logged in, thus, there is no console (window) for output or means of accepting user input except through a separate interface made available in the control panel.

I do not assume what you're doing now has anything to do with Dos, that remark was in reference to the other question that you asked and I answered several weeks ago.

... as for your " quite silly waste of memory" issue... you don't have to use the winsock control at all.  You can get all of the winsock's functionality straight from the API WSA calls, but it's much more difficult.  It would save you a few bytes of memory, but it will cost you many hours of development time.

If you are building a service for NT, I can tell you from experience because I have several that I've developed currently running on my server - the smallest VB program ran as a service will have about 2.5 MB of ram allocated to it by NT.  A hidden form will cost you about an extra 100 bytes.  I'm talking about the Form class not the code on the form because the code that handles the Winsock events would have to be there even if you could create a winsock object.


0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 1

Author Comment

by:mnichols
ID: 1456476
If you believe that hidden windows aren't anything to be concerned about as far as memory is concerned, then okay. I just thought it would be an accomplishment to be able to use controls without using forms. Thanks for the help.
--
Matt Nicholson
mnichols@cs.fit.edu
0
 
LVL 8

Expert Comment

by:mrmick
ID: 1456477
Matt,

The form will add bytes to the project, but very minimal compared to the bytes allocated anyway.  Of course, I'm talking about an empty form - which is essentially what we're talking about because anything associated with the objects on the form (the winsock control) would be necessary even if you could create the objects without the form.

Why the "C"?
0
 
LVL 1

Author Comment

by:mnichols
ID: 1456478
Well, the answer was acceptable, but not the one I was looking for. A code sample that would tell me exactly how to accomplish my task would deserve an A. Sorry, but I'm very demanding when it comes to answers
0
 
LVL 8

Expert Comment

by:mrmick
ID: 1456479
hmmm...

I thought I covered the explanation part pretty well.  You expected a code example of placing a control on a form?  My answer may not have been what you wanted - but it was the correct answer to your question.

Very demanding?  Do you realize that those who answer questions here do not get paid?

I'll try to keep in mind, before I offer an answer to one of your questions again, that you have a tendency to slap those who help you when you don't like the answer - even when the answer is correct.

0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
groupSumClump challenge 9 125
using web browser with BING 40 132
Spell Check in VB6 13 127
rhino JavaScript import, load 25 94
There is an easy way, in .NET, to centralize the treatment of all unexpected errors. First of all, instead of launching the application directly in a Form, you need first to write a Sub called Main, in a module. Then, set the Startup Object to th…
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question