Solved

registry and internet

Posted on 2000-03-24
23
296 Views
Last Modified: 2010-05-02
I have some questions if any experts can help me out.

I writing a program to detect and do a certain thing when user log on the internet.

First, I want to have a function that allow my program to automatically, hiddenly starts when windows starts.  It just like putting my program in the startup folder but I dont want to do so.  I think there is a way by adding it to the registry.  I want to be able to enable and disable the start up option at choice by running my program.  By the way, I dont want it to show its icon at the lower end of the windows where the clock appear, neither is on the task menu[ctr-alt-del].  But I want a tricky way to access to my program so no other users would be able to access to the program but me.

Second, how do I detect when user go to the internet.  The user would use dial-up to connect to the internet.  I noticed when user connect to the internet, a small two-lights computer appear at the bottom left of the screen.

I will accept the most complete and helpful comments as answer.

Thanks
cdloves
0
Comment
Question by:cdloves
  • 9
  • 6
  • 3
  • +3
23 Comments
 
LVL 32

Expert Comment

by:Erick37
ID: 2654389
Win 95/98, NT or both?
0
 
LVL 32

Expert Comment

by:bhess1
ID: 2654402
Sample code showing how to automatically start a program when windows starts using the registry (not the Startup folder):

http://vbaccelerator.com/codelib/inireg/regmisc1.htm

To ensure that the program doesn't show on the task bar:

http://vbaccelerator.com/codelib/winstyle/taskshow.htm

To hide a program from the Task List:

http://www.vb2themax.com/Item.asp?PageID=TipBank&ID=186

Hope these help...
0
 

Author Comment

by:cdloves
ID: 2654445
Eric,
I am looking for 95/98,  but it would be nice if you have both
0
 

Author Comment

by:cdloves
ID: 2654470
bhess1,

those examples seem little complicated...It will take me a while to check it out....so hang on.

Any comments for checking internet status?
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 2654645
you want to know right when an internet session begins?  or you just want to be able to check if there is an internet connection already established?
0
 
LVL 32

Expert Comment

by:bhess1
ID: 2654682
Nothing right now - you'll have to count on some of the other experts here for that.
0
 

Author Comment

by:cdloves
ID: 2654710
AzraSound, I want to know right when an internect session begins(is that how you call when the dialup finished and the small computer appear at bottom right?).  I want my program to execute the main statements when the internet first connected.  Well how about this...when a internet is first establish, I want my program to run its main function...Otherwise it just sit there and wait....

Thanks...I hope I made it clear...
cdloves
0
 
LVL 32

Expert Comment

by:bhess1
ID: 2654711
Well, actually, you might check out:

http://www.mvps.org/vbnet/code/network/internetgetconnectedstate.htm

Sample VB code to determine if you are connected.  However, it only works if IE4 or later is installed, as it uses a DLL from IE4.

Using this, you could have your background program check the connected state evert second or two (using the Sleep() api call to suspend processing in between)
0
 

Author Comment

by:cdloves
ID: 2654803
OK, here is my status so far...

I test the automacially start function and it "partially" works.  However, here is my sub main:

 Sub Main()
     AutoRun eOnce
    If MsgBox("hello", vbYesNo) = vbYes Then
        Exit Sub
    Else
        AutoRun eNever
    End If
 End Sub
....
After startup the comp, the prog runs and display a hello message, if I click on yes, another hello message will appear, and it will keep appearing until I click no.  Why is that happen?  

After I click no, the program exit and windows begin to load it startmenu and so on.  Then I run the program again, this time I click yes, the program exit...I restart the comp, program runs at start up, click yes on the message box, the msgbox appear again and again until I click no.

If you want to test out for yourself...have the class include.  Set the let property of autorun into sub and block out the get property...  See if you can help me out.
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 2654810
thats why i was asking...i only knew of a way to check if there was already a connection though I imagine there is another way with API.  You can monitor the system and be notified upon certain events occurring though I am not quite certain how its done.  But if you dont mind checking for a connection every few seconds with a timer control then I have the code that will do that.
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 2654929
youre program starts off calling SubMain from the module...so since you put that code in your module and you say "yes start my program" it will always call SubMain at the beginning.  You need to put that code somewhere else.  Perhaps in a formload event.
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 32

Expert Comment

by:bhess1
ID: 2654944
You are setting a new Registry key every time the program runs.  So, once the current RunOnce is done, the start-up sequence checks for more AutoRun keys, and re-starts the program from the new key.

You can't re-install the same Autorun key during the startup sequence.
0
 
LVL 14

Expert Comment

by:wsh2
ID: 2654948
No offense folks.. but what is cdloves up to?... Ahhhhhhh-chooooo, uh sorry.. I must be getting the flu.

cdloves.. what are you up to?.. <eg>.
0
 

Author Comment

by:cdloves
ID: 2655085
hahahah...

good question wsh2...

First of all, I main point in here is that I want to "block" my brother from going to the internet.  Because he is quite good at computer (he is a college student in CS major) so it would be very hard do it.  I want a program run in back ground and prevent him from going to the internet.  I enventually will disable ctr-alt-del so he can't end my program, he still can enable it and re-call the function it[I believe he can].  so I will need to hide it so that it would not dispay in task list in case he enables Ctr-Alt-Del.  Now, the next point is how will I do it so that I can use the internet myself but not him.  And I dont want him to figure out that I up to the trick.

Second of all, this is a good practice for me because I dont familiar much with API call.

Did that answer your question?  By the way, it would be nice if you answer me what you really thought I was up to... FAIR, right?

cdloves
P.S.  It was nice you brought this up.
0
 

Author Comment

by:cdloves
ID: 2655097
AzraSound, I put every thing in the formload and the result was the form act like the msgbox that is keep re-appearing after I close it.

Bhess1, I will take your word that I can't install same key...

By the way, you mention something about call Sleep() api call, how do I use it.  I hope my reply to wsh2 give you a general idea what I am "up to".

Thanks,
cdloves
0
 
LVL 32

Expert Comment

by:bhess1
ID: 2655196
You declare the API call as:

Declare Sub Sleep Lib "kernel32" ( _    ByVal dwMilliseconds As Long)


And use it where ever you want to pause your program:

(doing something here...)

Sleep 1000   ' pause program for 1000 milliseconds = 1 second

0
 

Author Comment

by:cdloves
ID: 2655350
so you mean I should use a:
while notoninternet
   sleep 1000
wend

to wait for internet connection 2 be made?
0
 

Author Comment

by:cdloves
ID: 2655358
I meant is that they way most programmers do while their program runs in back ground?
0
 
LVL 14

Expert Comment

by:wsh2
ID: 2655368
Thanks for writing cdloves.. <huge smile>. First of all.. Mom loves you too, Ok?.. <just kidding!> and <LOL>.

A word of caution in this though, add a switch to your program so that it only activates when you are around.. either that or don't stand under any open windows of the computer room whenever he gets on the machine and you are not around. Remember, everything of his is going to be be yours one day.. and hopefully the computer will still be in one piece like that Scooby Doo pass me down Lunchbox that you came to love.

Now, I want you to know.. what you are doing can get you thrown out of the League Of Justice Superhero Club. Batman, Superman, da Flash all kinda frown on this schtuff.. and don't be surprised if you do not get invited to their Chucky Cheese Pizza birthday parties and miss out on the singing mechanical bear there. Simply put, Superpowers are only to be used for "Good" and NOT "Evil".. I mean what if your Superpower should fall into the wrong hands? Well.. we would just have to go and bomb Iraq again.. Ok, I admit bombing Iraq is fun.. but you just gotta know some Mom in Iraq is really gonna get p*ssed.. when she can't get the shrapnel in the wall to shine up.. and well.. you know Moms.. she's gonna call you Mom and say it is all your fault.. and then your Mom is gonna jump on you and say.. "can't you act more like your older brother".. and once again you are going to feel left out. Being a Superhero with an older brother somedays can really be rough.. <sheesh>.

Anyhow.. good luck with your project.. and thank you for enduring my silliness.. <smile>.



0
 
LVL 27

Expert Comment

by:Ark
ID: 2655959
Hi
1. Starting Your Application When Windows Boots

Add a string entry in HKLM\Software\Microsoft\Windows\CurrentVersion\Run.  The entry's name should be the name of your application (ex: MyApp).  Its value must be the short path to your application (ex. C:\Windows\MyApp.exe).

2. How to hide programm from task manager and from Ctrl-Alt-Del:
http://www.codearchive.com/vbasic//taskhide.zip or
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?lngWId=1&txtCodeId=2394 (the easiest one) or
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?lngWId=1&txtCodeId=2393

3. How to check active Inet connection
http://www.freevbcode.com/ShowCode.Asp?ID=632 - you can choose any of three ways to detect if connection is active. If you use dial up the first way is the easiest

4. How to disconnect from the internet
http://www.vb-world.net/internet/tip21.html

5. Good Luck :-). BTW, take a look at http://www.planet-source-code.com/vb/scripts/ShowCode.asp?lngWId=1&txtCodeId=2218 (IMPORTANT - read disclaimer first!!!)
Cheers
0
 
LVL 32

Accepted Solution

by:
bhess1 earned 150 total points
ID: 2661130
Unless you want your background program to take a significant chunk of processing time, or can tie it into a windows call, so that an event fires off when your program needs to act, then the Sleep() method is usually used.  

During the Sleep interval, your program won't use any significant CPU resources, allowing you to use your PC as normal.  A DoEvents or other type of loop will use a significant chunk of processing time.

I'd bet that a 1 second interval between checks would be often enough for your purpose.
0
 

Author Comment

by:cdloves
ID: 2661805
I got the program to run as I wanted.  Thank you all for giving me comments.

Because I used bhess comments the most to write my program so I will give the points to him.

Once again, thank you all for helping me out.

Thanks,
cdloves
0
 
LVL 14

Expert Comment

by:wsh2
ID: 2661938
I hope your brother beats the living crap out of ya... nananananannanana <tongue out>.. so there !!! <just kidding.. LOL>.. Good luck with your project !!!! <smile>.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

759 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now