|
Hello everyone! My name is Emmanuel and I new to dis site and also to programming. I am trying to write a program with vb6.0 that can be use to lock pc in a cafe. I have successfully designed d program but d problem is hw can i disable/enable d ctrl+alt+del keys so that d program cannot b quit. Also, som people might wnt to switch off d system & reboot so that they can have access. Now hw can i make the program autorun at windows startup? I know dragging d exe app into d startup folder can solve dis but d problem is that i'm not writing dis program 4 my self and i won't b there when my clients will install it. So, pls give me d code dat will add d program to d startup folder and d code to remove it if d user click on disable autorun. I am using windows 7 ultimate OS. Tnx in adv.
|
|
|
|
|
Since you're new to programming, I HIGHLY suggest you drop VB6 right now and go get VB.NET Express. It's free from here[^].
Save yourself the grief of learning a bunch of bad habits that VB6 will teach you and you'll get far more features and flexibility by using .NET instead.
Otekpo Emmanuel wrote: hw can i disable/enable d ctrl+alt+del keys
You can't trap Ctrl-Alt-Del. It's impossible to disable it.
Since you're code running AS THE USER when it starts from double-clicking it or from the Run key in the Registry, the user can terminate it any way they want and you can't stop that from happening. Users are always able to terminate an app running in their security context.
The solution is to move your code to somewhere that normal users don't have permissions to terminate, such as a Windows Service running as Local System. VB6 cannot write Windows Services (without hacking it in!), but VB.NET can.
Truthfully, a café application like this is far from trivial to write, secure, test (you ARE testing this for security, correct?!) and support.
|
|
|
|
|
Ok Dave, thanks for your advice and I promise not to use such words again. You advice me to use Vb.Net and just as I said before, I'm new to programming and I don't any knowledge about Vb.Net. So would you please give some guidelines to abide to. And a site that can give me more experience on Vb.Net. Thanks.
|
|
|
|
|
Ok Dave, thanks for your advice and I promise not to use such words again. You advice me to use Vb.Net and just as I said before, I'm new to programming and I don't any knowledge about Vb.Net. So would you please give some guidelines to abide to. And a site that can give me more experience on Vb.Net. Thanks.
|
|
|
|
|
Guidelines?? For what?? No site can give you "more experience". The only thing that's going to do that is writing code, writing more code, and finally writing even more code.
|
|
|
|
|
Less of the textspeak - we are adults here!
It's well known that if all the cat videos and porn disappeared from the internet there would be only one site left and it would be called whereareallthecatvideosandporn.com
|
|
|
|
|
There's an older article on configuring XP as a kiosk machine[^]; might still have some good clues
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Hello everyone! My name is Emmanuel and I'm new to programming. I designed a name dictionary with v6.0, where som1 can search 4 d meaning and origin of his name. Everytin is wrking fine. But when i make d project exe and try to run it in another system, it shows d database path is not a valid path but it will run fine in my system. Som1 out there shud hlp me plzzzzz. Tnx in adv.
|
|
|
|
|
Otekpo Emmanuel wrote: Som1 out there shud hlp me plzzzzz
This will almost certainly not happen as you are coding in a language that is DEAD , as Dave suggested get VB.Net express and start again.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I've a big interrogation concerning sound playback (WMP.lib)!
This code should play a sound, then compute...but it computes then play the sound!
Class MainWindow
Dim writingPath As String = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) & "\_UI Sounds\"
Dim uiPlayer As New WMPLib.WindowsMediaPlayer
Private Sub MainWindow_Loaded(sender As Object, e As System.Windows.RoutedEventArgs) Handles Me.Loaded
RunTest()
End Sub
Private Sub RunTest()
Debug.Print("Started!")
uiPlayer.URL = writingPath & "son1.wav"
uiPlayer.controls.play()
Dim a As Integer = 0
For i As Integer = 0 To 999999999
a = i
Next
Debug.Print("Done!")
End Sub
End Class
I thought that I perhaps should run the sound in a thread to be sure that it's played by its own!?
But this gives the same result
Imports System.Threading
Class MainWindow
Dim writingPath As String = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) & "\_UI Sounds\"
Dim uiPlayer As New WMPLib.WindowsMediaPlayer
Dim uiThread As Thread = New Thread(AddressOf PlayFile)
Private Sub MainWindow_Loaded(sender As Object, e As System.Windows.RoutedEventArgs) Handles Me.Loaded
RunTest()
End Sub
Private Sub RunTest()
uiThread = New Thread(AddressOf PlayFile)
uiThread.Start()
Debug.Print("Started!")
Dim a As Integer = 0
For i As Integer = 0 To 999999999
a = i
Next
Debug.Print("Done!")
End Sub
Private Sub PlayFile()
uiPlayer.URL = writingPath & "son1.wav"
uiPlayer.controls.play()
End Sub
End Class
How should I please proceed to hear my sound 'instantly'?
What's my mistake?
Thanks for your help!!
|
|
|
|
|
You've moved the wrong bit to the background thread.
Dim computeThread As Thread
Private Sub RunTest()
uiPlayer.URL = writingPath & "son1.wav"
uiPlayer.controls.play()
computeThread = new Thread(AddressOf Compute)
computeThread.Start()
End Sub
Private Sub Compute()
Debug.Print("Started!")
Dim a As Integer = 0
For i As Integer = 0 To 999999999
a = i
Next
Debug.Print("Done!")
End Sub
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
There are two possibilities to handle audio playing: one involves the message pump, the other one involves callback methods. I guess the WMPLib.WindowsMediaPlayer uses the message pump, and runs in the GUI thread of your application (as you explicitly call it uiPlayer). In that case, the messages can only be dealt with when the GUI of your apllication is ready to handle them.
You may test that hypotheses by adding an Application.DoEvents() to your for loop (do not do that for production code): playing should now be possible.
|
|
|
|
|
It doesn't work better.
Well, I had posted a simple code, hoping that it would be more clear for users to help me...but I'm afraid that I'd better post something very similar to my actual code..if I want the problem to be clearly exposed...and help you to try to help me
There's a sound class, called UISound:
Imports System.Threading
Public Class UISound
Dim writingPath As String = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) & "\_UI Sounds\"
Public Shared WithEvents uiPlayer As New WMPLib.WindowsMediaPlayer
Public Shared uiThread As Thread = New Thread(AddressOf ReceiveSound)
Public Shared Sub ReceiveSound(ByVal url As String)
uiThread = New Thread(AddressOf PlayFile)
uiThread.Start(url)
End Sub
Public Shared Sub PlayFile(ByVal url As String)
uiPlayer.URL = writingPath & url
uiPlayer.controls.play()
End Sub
End Class
The sound is called from a sub in the MainWindow...which itself fires other subs in cascade that involve a heavy compute time:
Sub one()
UISound.ReceiveSound("sound1.wav")
Dim a As Integer = 0
For i As Integer = 0 To 999999999
a = i
Next
Two()
End Sub
Sub two()
Dim a As Integer = 0
For i As Integer = 0 To 999999999
a = i
Next
Three()
End Sub
Sub Three()
Dim a As Integer = 0
For i As Integer = 0 To 999999999
a = i
Next
End Sub
It appears that the sound is played after the whole "cascade" is runned, so after Sub Three() End.
If you try this code you will verify that inserting
System.Windows.Forms.Application.DoEvents()
after uiPlayer.controls.play()...doesn't work better
Thanks for your help!!
|
|
|
|
|
I have posted similar question on StackOverflow[^]. I am unable to find the solution as yet
|
|
|
|
|
Please don't assume that CodeProject members are going to logon to SO just to read your question.
Veni, vidi, abiit domum
|
|
|
|
|
Right!
I pasted code here:
Code[^]
I get Invalid Object Array error on CopyObject line
|
|
|
|
|
Hi,
I have to get a directory file list, filtered on multiple extensions...and sorted!
I use this, which is the fastest way I've found to get dir content filtered on multiple extensions:
Dim ext As String() = {"*.jpg", "*.bmp","*png"}
Dim files As String() = ext.SelectMany(Function(f) Directory.GetFiles(romPath, f)).ToArray
Array.Sort(files)
and then use an array sort.
I was wondering (and this is my question ) if there would be a way to do the sorting IN the same main line? A kind of:
Dim files As String() = ext.SelectMany(Function(f) Directory.GetFiles(romPath, f)[B].Order By Name[/B]).ToArray
and, if yes, if I would gain speed doing this instead of sorting the array at the end (but I would do my test and report..as soon as I get a solution!!)?
Thanks for your help!!
|
|
|
|
|
Jayme65 wrote: if there would be a way to do the sorting IN the same main line? A kind of: You can combine methods on a line, but that makes it a compound statement; it still execute a statement at a time.
Getting a list and sorting are two distinctly different things.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Jayme65 wrote: ext.SelectMany(Function(f) Directory.GetFiles(romPath, f))
This part gets the list three times, and filters it three times. Next, you turn it into an array, and sort that. It'd (probably) be faster to get the list once and filter it. Since GetFiles already returns an array, there's no need to convert it.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
I'd like to have charmap.exe open with the same font I'm using in my application's main window. But I've had no success passing arguments to it. I had assumed that:
Process.Start("charmap.exe", "Arial")
would get it done. But this has no effect. Suggestions?
XAlan Burkhart
|
|
|
|
|
That's because CharMap doesn't take any command line arguments.
AFAIK, the only way to open it at a specific font would be to launch it, make sure the window has the focus and then use SendKeys to send the font name, essentially typing it into the drop down list in CharMap.
|
|
|
|
|
I had considered this but was wanting to send arguments instead. But SendKeys works perfectly. Thanks much for the info.
XAlan Burkhart
|
|
|
|
|
Arguments only work when the target app is expecting them, and only if you use the switches it expects.
|
|
|
|
|
You can do this via the registry.
Dim CharMap_Key As RegistryKey = Registry.CurrentUser.OpenSubKey("Software\Microsoft\CharMap", writable:=True)
Dim currentfont As String = CStr(CharMap_Key.GetValue("Font", defaultValue:=""))
CharMap_Key.SetValue("Font", "Arial")
Dim proc As Process = Process.Start(Environment.SystemDirectory & "\charmap.exe")
|
|
|
|
|
In my case, charmap.exe already opens with "Arial" as the selected value - Of course, if you have a different font in your app you'll need to go the SendKeys-Way.
|
|
|
|