CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9
  1. #1
    Join Date
    Oct 2001
    Posts
    8

    running a C program from inside VB

    Hi all
    I have a C compiled code that I want to run from inside VB5.
    The program run but it is not doing what it does if I run it from the explorer. I guess the problem is that it was written under DOS.
    In fact it has a dos.h library and using a ABSREAD function.
    1. is it possible to run it anyway from inside VB and obtain a desired result?

    thanks in advance
    elporti
    2. Can someone help me to find another funtion that replaces ABSREAD with another that could run under Windows(95/98)?


  2. #2
    Join Date
    Oct 2001
    Location
    Phoenix, AZ
    Posts
    54

    Re: running a C program from inside VB

    1. probably not. at least i don't think it would be easy.

    2. what specifically are you trying to read from the disk? my assumption based off of what ABSREAD does, you should look at the DeviceIOControl function.

    Software is like sex, it's better when it's free - Linus Torvalds
    Software is like sex, it's better when I get paid for it. - me

  3. #3
    Join Date
    Jun 2001
    Location
    Israel
    Posts
    228

    Re: running a C program from inside VB

    I guess you should run it using the built-in DOS. The problem is that you don't know which file it is (well, i don't... i guess there is a way to know). In winXP for example its cmd.exe so you should run cmd.exe c:\myprog.exe, i guess it should have the same results as using explorer.

    ----------
    The @host is everywhere!
    ----------

  4. #4
    Join Date
    Oct 2001
    Posts
    8

    Re: running a C program from inside VB

    I am trying to determine if the proper diskette is placed in the Arive. When you use Absread you are reading data written in a disk.
    What I am trying to do is to translate the AbsRead function (working under DOS) to a functions that would do the same under Windows. I have found that there is a library called FS_DirectDiskIO that could be the one I am looking for but I dont know if it belongs to C, C++, visual, C#, etc. Maybe someone knows and could help me.

    elporti


  5. #5
    Join Date
    Oct 2001
    Location
    Phoenix, AZ
    Posts
    54

    Re: running a C program from inside VB

    What are you searching for on the drive? A file? The volume name?

    Software is like sex, it's better when it's free - Linus Torvalds
    Software is like sex, it's better when I get paid for it. - me

  6. #6
    Join Date
    Oct 2001
    Posts
    8

    Re: running a C program from inside VB

    Yes, I am trying to read the volume name. Any suggestion of how can I do it?

    elporti


  7. #7
    Join Date
    Dec 1999
    Location
    Dublin, Ireland
    Posts
    1,173

    Re: running a C program from inside VB

    You can use the GetVolumeInformation API call.


    '\\ Declaration
    Declare Function GetVolumeInformation & _
    Lib "kernel32" Alias "GetVolumeInformationA" & _
    (byval lpRootPathName as string, byval & _
    lpVolumeNameBuffer as string, byval & _
    nVolumeNameSize as Long, lpVolumeSerialNumber as & _
    Long, lpMaximumComponentLength as Long, & _
    lpFileSystemFlags as Long, byval & _
    lpFileSystemNameBuffer as string, byval & _
    nFileSystemNameSize as Long) as Long





    HTH,
    Duncan

    -------------------------------------------------
    Ex. Datis: Duncan Jones
    Merrion Computing Ltd
    http://www.merrioncomputing.com
    Check out the new downloads - ImageMap.ocx is the VB control that emulates an HTML image map, EventVB.OCX for adding new events to your VB form and adding System Tray support simply, MCL Hotkey for implemenmting system-wide hotkeys in your application...all with source code included.
    '--8<-----------------------------------------
    NEW -The printer usage monitoring application
    '--8<------------------------------------------

  8. #8
    Join Date
    Oct 2001
    Posts
    8

    Re: running a C program from inside VB

    Thank you Duncan for your reply. It sounds like it is what I'm looking for.
    Could you write an example of how to call this function? It would be something like

    qcode = GetVolumeInformation(A,,,,,) ??

    elporti


  9. #9
    Join Date
    Oct 2001
    Location
    Phoenix, AZ
    Posts
    54

    Re: running a C program from inside VB

    You could use the FileSystem object. In your project, set a reference to Microsoft Scripting Runtime.


    Dim fso as FileSystemObject
    Dim d as Drive
    set fso = new FileSystemObject
    set d = fso.GetDrive("a:")
    If d.IsReady then
    MsgBox d.VolumeName
    End If
    set fso = nothing
    set d = nothing




    Software is like sex, it's better when it's free - Linus Torvalds
    Software is like sex, it's better when I get paid for it. - me

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured