Transform in string..

New to FreeBASIC? Post your questions here.
h3llm45t3r
Posts: 18
Joined: Jun 22, 2008 0:31
Location: Brazil

Transform in string..

Postby h3llm45t3r » Aug 17, 2008 21:31

someone help me xD~~..


i want to enter a code on cmd by fbid .. and transform one line on a string ..
for a example .. i want to read HOST NAME ( computer name ) with "systeminfo" commando ..

cmd.exe /c "systeminfo | find "Host name"
or
cmd.exe /c "systeminfo | find "Nome do host" ( in portuguese )

the result is:
Nome do host: CRAZY-PC2


i want to transform this result in a string .. ^^ ..

if someone know this .. please say me xD~~



obs: sorry by the bad english ;x
voodooattack
Posts: 605
Joined: Feb 18, 2006 13:30
Location: Alexandria / Egypt
Contact:

Postby voodooattack » Aug 17, 2008 22:34

Code: Select all

   
    dim cmd as string = !"systeminfo | find \"Host Name\""

    open pipe cmd for input as #1
   
        do
            dim s as string
            input #1, s
            print s
        loop until eof(1)
   
    close #1
   
    sleep


and now the proper method:

Code: Select all

    #include "windows.bi"
   
    dim l as integer
    dim pcName as string
   
    GetComputerName(0,@l)
   
    pcName = space(l)
   
    GetComputerName(pcName,@l)
   
    print pcName
   
    sleep

Return to “Beginners”

Who is online

Users browsing this forum: No registered users and 1 guest