Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

GetNumTasks Problem

Status
Not open for further replies.

BootMeUp

MIS
May 31, 2000
35
US
My code is running command line DOS from a batch file and producing text file output. The command needs be done before the text file is rewritten (else, user gets old message). I'm using GetNumTasks function to test for this. Error occurs at "Num_Apps = GetNumTasks()". The message is: "Run-Time error '53'; File not found:Kernel".
Below is code:
====================================================
Private Declare Function GetNumTasks Lib "Kernel" () As Integer

Private Sub Command1_Click()
Dim Num_Apps As Integer, NewFile As Integer
Dim File_Data As String, DosCmd As String
Dim X As Integer
'Create a batch file with the DIR *.EXE command
'and redirect the output to a textfile DIRLIST.TXT.
DosCmd = "DIR c:\*.* > c:\DIRLIST.DAT"
NewFile = FreeFile
Open "C:\DIRBAT.BAT" For Output As #NewFile
Print #NewFile, DosCmd
Close #NewFile
'Call the Shell command to execute DIRBAT.BAT.
==>Num_Apps = GetNumTasks() <===========This is where error occurs
X = Shell(&quot;C:\DIRBAT.BAT&quot;, 2)
'Wait until DIR has finished doing its thing.
Do While GetNumTasks() <> Num_Apps
X = DoEvents()
Loop
'Display the filenames in the Text Box.
NewFile = FreeFile
Open &quot;C:\DIRLIST.DAT&quot; For Input As #NewFile
Text1.Text = &quot;&quot;
While Not EOF(NewFile)
Line Input #NewFile, File_Data
Text1.Text = Text1.Text & File_Data & Chr(13) & Chr(10)
Wend
Close #NewFile
End Sub
Private Sub Command2_Click()
End
End Sub
====================================================
This program was used as a test base for other programs
which perform command line processing.
=====================================================
Any help will be appreciated
Steve A.

[sig][/sig]
 
I run into the same problem, it lies in the fact that newer PCs run kernel32, not kernel. But the new problem is:

[Run-time error '453']
Can't find DLL entry porint GetNumTasks in Kernel32

Anyone know how to fix this?

Larry
 
If you are trying to do what BootMeUp was trying to do, try using [tt]WaitForSingleObject[/tt] instead.

You'll find an example in faq222-32.
VCA.gif
 
Or, avoid the DOS thinnggyyyy altogether and use the VB DIR command to populate the Test box (although I can't reall see using a textbox for this when a combobox or listbox would be easier to read/use).

MichaelRed
mred@att.net

There is never time to do it right but there is always time to do it over
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top