Solved

Winsock control and formless (windowless) applications

Posted on 1998-02-08
7
487 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Excel file not created as expected 7 110
Problem to With line 4 86
VBA: loop recent folder and copy txt file. 8 56
Set WorkSheet  not Working 9 62
If you haven’t already, I encourage you to read the first article (http://www.experts-exchange.com/articles/18680/An-Introduction-to-R-Programming-and-R-Studio.html) in my series to gain a basic foundation of R and R Studio.  You will also find the …
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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.
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…

734 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