|
We'll I'll be! I did run an exe (before I posted) and redirected the output to a file just to make sure and it worked, but I tested it in VB and sure enough it didn't happen.
It *does* work, but the catch is you have to have the console open, and it must stay open. If I run a console program outside of an open shell (command) window it closes before STDOUT has time to be written to.
So, I tried several things. This involved me actually piping a char stream to my app directly (skipping output.txt). That worked, but it still didn't allow me to make sure the Window was hidden.
So, I got the idea to use a batch file. Lo and behold it did the job. No window and output.txt was there. This is because (I assume) of the way a batch file is handled -- it was an execution on top of an execution. The only thing left to do was make sure the program waited long enough to let the text file be created. So, I checked to make sure the process terminates.
Posting the code in this message isn't sensible because I also created a simple C console application that prints to STDOUT and an example batch file to run it. So, I ZIPped up the project and posted it for download on my (soon to be) website. Just scan for viruses as a precaution. I'm paranoid about this ever since I got CIH (back in the day).
Oh, and don't forget to put myprog.exe and myprog.bat in your C:\ directory.
File: http://dev.imputek.com/StdOut.zip
Jeremy L. Falcon
"The One Who Said, 'The One Who Said...'"
Homepage: imputek.com
|
|
|
|
|
hi Jeremy
thanks for this but this reads in from the file once the application (exe) is finished. i want to catch the stuff while the application is still running. is this possible? while the exe is running and sending stuff to screen, i want to catch the output written on screen and print it in the text box.
please let me know if this is possible.
kind regards
Mohith
be the change that you want to see in the world
|
|
|
|
|
It's possible, but it won't be easy. This will involve you controlling the process and the process' console manually -- which takes some work.
If you have MSDN installed, check out...
mk:@MSITStore:C:\Program%20Files\Microsoft%20Visual%20Studio\MSDN\2001JAN\1033\fileio.chm::/hh/winbase/conchar_4p6c.htm
And look into "Using the Console" and "Console Reference". If you don't have MSDN installed, then you can look at MSDN Online.
Jeremy L. Falcon
"The One Who Said, 'The One Who Said...'"
Homepage: imputek.com
|
|
|
|
|
Hi !
I'm building an App using Visual Basic 6, where I would like to display many ActiveX controls.
The number and types of ActiveX to display is not hard-coded in the App, but rather put in a text file that would be read during initialization of the App, thus allowing me to add/remove ActiveX controls without recompiling my App.
My problem is I don't know how to use an ActiveX control in VB without registering it (Project->Component) and putting it into a form. I would like to register it during code execution and placing it into my form dynamically.
Anyone knows how to do that ?
Thank you for your help !
Jerome
|
|
|
|
|
To simply put it, it's a whole heck of a lot easier to reference all the ActiveX controls (Project/Components...) you'll need and create them as needed. Also, if you use the package and desployment wizard it'll make sure the OCXs are included in your installation.
I am not sure what it is exactly you are looking to do, but if you do reference the controls, you can use a control array along with the Load statement to create new indices at runtime.
You don't have to use a control array. Reference the rich edit control in your project, Uncheck "Remove information about unused ActiveX Controls" from Project Properties/Make. And run the following code...
Dim MyControl As Control
Private Sub Form_Load()
Set MyControl = Me.Controls.Add("RICHTEXT.RichTextCtrl.1", _
"RichText1", Me)
MyControl.Text = "I'm Dynamic!"
MyControl.Font.Bold = True
MyControl.Font.Italic = True
MyControl.Visible = True
End Sub
Private Sub Form_Resize()
If IsObject(MyControl) Then _
MyControl.Move 0, 0, Me.ScaleWidth, Me.ScaleHeight
End Sub
Private Sub Form_Unload(Cancel As Integer)
If IsObject(MyControl) Then Set MyControl = Nothing
End Sub
However, in doing this you'll need to know the ProgID for the ActiveX control. I generally, place the control on the form, save it, use the .frm file to get the class name, run it, and get an error message giving me the ProgID. You can also get it from the registry, but I'm lazy.
If you don't register the control in the project you may have to deal with licensing info in your code. Most MS ActiveX controls require a license to be used. You could create one manually, but this becomes more of a pain than it's worth.
Good luck...
Jeremy L. Falcon
"The One Who Said, 'The One Who Said...'"
|
|
|
|
|
I'm new to Visual Basic. Is there any way that I could give a visual basic 6 application the look/feel of a java swing app ?
|
|
|
|
|
i want to send a picture on the plotter of A0 size through my visual basic programe.reply me soon plz plz plz plz.
talha amin
|
|
|
|
|
hi, i would like to do something like that:
the website targeted use PHP to login with a username and a password.
and then, some menu is shown, (all using .php or .php3 extension for viewing pages.)
the fact is, if i do not log with my user/password within internet explorer, i can't even retrieve files i want using internet explorer.
but, even after logging in, and when i am able to download any file ending with .php3?someparam=somevalue&another=anothervalue etc...
when i use a offlinebrowser application to save all pages i want, the external application finally download a page which says i'm not logged on. although i can still download that page opening an internet explorer windows... (and setting the offline browser 'spider' to identify itself as IE doesn't solve the problem.)
so i have figured out that i need something, which will log in using a specified username/password, and then, will download all files linked from a single url. (and that need to work with either .php or .php3?x=1&pass=2 files...)
how can i do that?
|
|
|
|
|
|
Hi
Is there a way of converting the path written in 32 bit way to 16-bit in VB?
e.g. i want to convert c:\my documents\try\usinggrids to
c:\mydocu~1\try\usingg~1
please do let me know if there is a way
thanks
Mohith
be the change that you want to see in the world
|
|
|
|
|
Check out the GetShortPathName() API.
Jeremy L. Falcon
"The One Who Said, 'The One Who Said...'"
|
|
|
|
|
Hello !!!
I would like to combine a Flash 5 animation to VB 6.0 software as a button. i.e. when the mouse is on the button the anination is start to move, otherwise, there is a button with a static graghic.
Thank you very much !! I hope you can help me.
Ahuva.
|
|
|
|
|
Hi Ladiez & Gentz,
this is an example out of my Learn Scripting In 2 Hours Book (Yeah Right)
it opens excel and then creates a new workbook and changes some of the cell properties and enters some info
but what i want is to open excel and then OPEN a workbook - anyone got any idea on how to
thanks in advance
Alex T
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
L_Welcome_MsgBox_Message_Text = "This script will display Windows Scripting Host properties in Excel"
L_Welcome_MsgBox_Title_Text = "Windows Scripting Host & Excel"
'Excel Sample
Dim objXL
Set objXL = WScript.CreateObject("Excel.Application")
objXL.Visible = True
objXL.Workbooks.Add
objXL.Columns(1).ColumnWidth = 20
objXL.Columns(2).ColumnWidth = 30
objXL.Columns(3).ColumnWidth = 40
objXL.Cells(1, 1).Value = "Property Name"
objXL.Cells(1, 2).Value = "Value"
objXL.Cells(1, 3).Value = "Description"
objXL.Range("A1:C1").Select
objXL.Selection.Font.Bold = True
objXL.Selection.Interior.ColorIndex = 1
objXL.Selection.Interior.Pattern = 1 'xlSolid
objXL.Selection.Font.ColorIndex = 2
objXL.Columns("B:B").Select
objXL.Selection.HorizontalAlignment = &hFFFFEFDD 'xlLeft
Dim intIndex
intIndex = 2
Sub Show(strName, strValue, strDesc)
objXL.Cells(intIndex, 1).Value = strName
objXL.Cells(intIndex, 2).Value = strValue
objXL.Cells(intIndex, 3).Value = strDesc
intIndex = intIndex + 1
objXL.Cells(intIndex, 1).Select
End Sub
'Show WScript Properties
Call Show("Name", WScript.Name, "Application Friendly Name")
Call Show("Version", WScript.Version, "Application Version")
Call Show("FullName", WScript.FullName, "Application Context: Fully Qualified Name")
Call Show("Path", WScript.Path, "Application Context: Path Only")
Call Show("Interactive", WScript.Interactive, "State Of Interactive Mode")
'Show Command line Arguments
Dim colArgs
Set colArgs = WScript.Arguments
Call Show("Arguments.Count", colArgs.Count, "Number of command line arguments")
For i = 0 To colArgs.Count - 1
objXL.Cells(intIndex, 1).Value = "Arguments(" & i & ")"
objXL.Cells(intIndex, 2).Value = ColArgs(i)
intIndex = intIndex + 1
objXL.Cells(intIndex, 1).Select
Next
'Welcome
Sub Welcome()
Dim intDoIt
intDoIt = MsgBox(L_Welcome_MsgBox_Text, vbOkCancel + vbInformation, L_WelcomeTitleText)
If intDoIt = vbCancel Then
WScript.Quit
End If
End Sub
|
|
|
|
|
Hi all
how to create a reusable control program for web database. Please give me
some example for the reusable controls.
Regards
Nancy
Nancy
|
|
|
|
|
Hi,
I have connected a database to a DataGrid in VB6, but I need to do 2 things with it.
1, I want to sort the database alphabetically by a certain field, before it is displayed in the DataGrid.
I have tried using some SQL but it doesnt like it. Does anyone know how to do this, or if there is a specific 'Reference' or 'Component' which needs adding?
I can add, amend and delete records from the database, I just cant sort it!
Here is code I am using to connect to the database and table:
Dim strQ As String
strQ = "DRIVER={Microsoft Access Driver (*.mdb)};" & _
"DBQ=" & App.Path & "\lottery.mdb"
cnControls.Open strQ
rsControls.Open "syndicate1", cnControls, adOpenKeyset, adLockOptimistic
Set grdControls.DataSource = rsControls
2, The second problem I have, is with the display of the DataGrid in VB. The database table is automatically read into the DataGrid, and I want to customize the width of the 'fields' of the DataGrid.
Does anyone know how to do this?
At present, some columns are too narrow or wide for the data being displayed. Because of this, some field names arent fully visible.
Any help will be greatly appreciated,
Many Thanks, Matt
|
|
|
|
|
question 1)
You can use the sort method of the rs object. SQl should work as well.
rsControls.sort= "lname DESC, fname ASC"
or
rsControls.Open "select * from syndicate1 order by syndicate1.lname ASC", cnControls, adOpenKeyset, adLockOptimistic
question 2)
I belive you are looking for the datagrid.defcolwidth property.
|
|
|
|
|
I want to know how to process a Word document using VBA.Can you tell me where are the information?thank you!
Besides VBA,which tools can do the same work,SQL?C++builder?
If you can find information about this,please tell me.
For i know little English,I hope you can tell me the particular web sites.Thank you very much!
huang chun shen
|
|
|
|
|
I want to know how to process a Word document using VBA.Can you tell me where are the information?thank you!
Besides VBA,which tools can do the same work,SQL?powerbuilder?
If you can find information about this,please tell me.
For i know little English,I hope you can tell me the particular web sites.Thank you very much!
|
|
|
|
|
Can I Create Excel files using ADO's As we do for mdb files.
Thanks in advance
Sudhakar
|
|
|
|
|
You can if you install (and use) the ODBC driver for Excel. You will need to set the ConnectionString property (i think) appropriately. Look in help for ConnectionString there is probably an example.
--
David Wengier
Sonork ID: 100.14177 - Ch00k
|
|
|
|
|
Hi!
i'm in a bit of a time crunch, so the sooner someone can answer this the better...
i'm trying to script an uninstall for an application (the uninstaller is run via application). i can get the message box prompt confirming the uninstall to pop up, but i can't seem to be able to send keys to it. Unfortunately, there is no silent uninstall or force yes.
Here's my code snippet:
wsh.Run sUninstallCmd
wsh.AppActivate "Confirm Uninstall"
WshShell.SendKeys "{ENTER}", True
Confirm Uninstall is the header for the message box (and the text displayed when i alt+tab)
Any help is appreciated... obviously this is not doing the trick.
|
|
|
|
|
Hi All,
Can anyone tell me why I'm getting a "type mismatch" in the following code:
Thanks in advance...'
******************************
Dim strgate
set IPConfigSet = GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery _
("select IPAddress, DefaultIPGateway from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
for each IPConfig in IPConfigSet
strgate = IPConfig.DefaultIPGateway(0)
next
WScript.Echo strgate(0)
|
|
|
|
|
I want to load image in Menu and ButtonMenu .Can you help me? Thanks
|
|
|
|
|
Hi All...
I need to catch the message that is sent to the printer when a user presses print on any app. What API's should i use.
What i want to do is catch a print request to a printer log the user name and password and then print a report sometime in the future...
Anyone have any ideas...
Shot in advance...
budgie
-+= TTFN =+-
|
|
|
|
|
You can do this, but I do not think that you will be able to do it in VB. And if you can do it, it will be a lot of work.
You will need to use C++ or some other language that allows you to access pointers. If you are still interested let me know.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|