Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Beginning VB 6
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 9th, 2006, 11:11 PM
Friend of Wrox
 
Join Date: Mar 2005
Location: , , .
Posts: 264
Thanks: 0
Thanked 0 Times in 0 Posts
Default how to put result of shell function into variable

Hi all .I have difficulty outputing the value of shell function into massagebox by using regoutput variable. Currently the shell function writes the output to .reg file but i want i want to output it to massage box but it never works!! The output value is list of registery information which are half a page char mostly .

i tried diffrent datatyes and i got diffrent 4 digit integer each time!!
Below is the code and it writes the correct registery values into .reg file but i want to display it in massagebox and non of the data types works!!

Is there any way to display the registeiory information directly into massage box instead of writing it to reg file.?
since i evantually want to get rid of wirting to file process .
I be happy if some expert help me.Thanks



Code:
Private Sub Reg(Path As String)

Dim regoutput

task_id  = shell("Regedit.exe /e " & Chr(34) & Path & Chr(34) & " " & Chr(34) & _
"HKEY_CURRENT_USER" & "\" & "Software\me\" & Chr(34))
'The Char For " is Chr(34)

MsgBox "shell function output: "+regoutput
End Sub

Private Sub Save_Click()


On Error Resume Next

CD.DialogTitle = "Save Registry Backup File As..."
CD.InitDir = App.Path
CD.Flags = &H4
CD.Filter = "Registry File Format (*.reg)|*.reg"
CD.ShowSave

If InStr(CD.FileName, ".reg") Then

Call Reg(CD.FileName)

DoEvents

Text1.Text = CD.FileName


End If

End Sub
Reply With Quote
  #2 (permalink)  
Old April 20th, 2006, 11:42 AM
Friend of Wrox
 
Join Date: Nov 2004
Location: Port Orchard, WA, USA.
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Method,

In VB you can add a literal " to a string with 2 quotes in a row. So
Code:
    task_id = shell("Regedit.exe /e " & Chr(34) & Path & Chr(34) & " " & Chr(34) & _
                    "HKEY_CURRENT_USER" & "\" & "Software\me\" & Chr(34))
                    could be
Code:
    task_id = shell("Regedit.exe /e """ & Path & """ ""HKEY_CURRENT_USER\Software\me\""")


Inasmuch as your code succeeds in creating a file, why don't you just open that file from VB, and read its contents into a message box? I recommend using the FileSystemObject to do this—I just love its simplicity.

(By the way: your code is not creating the file, RegEdit.exe is.)
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Use of VB.NET's Shell function in C# jude_wong C# 8 December 16th, 2005 07:49 PM
put a space in between each variable crmpicco Javascript How-To 1 June 7th, 2005 11:58 AM
Using the Shell Function RAPSR59 Access 1 April 13th, 2005 07:14 AM
shell function problem bml Excel VBA 1 February 12th, 2005 05:42 PM
Shell Function Question SerranoG Access VBA 4 November 12th, 2003 07:57 PM



All times are GMT -4. The time now is 09:30 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.