Solved

Winsock control and formless (windowless) applications

Posted on 1998-02-08
7
471 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
ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

 
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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

773 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