Hi all,
This is related to a previous query I had regarding embedding DOS sessions in a form, which I have realise I am probably not going to be able to do. What I need to do is the following:
- Attempt to map a drive to a remote machine (I know the user name and password)
- Determine whether or not this process has been successful and act accordingly.
At the moment, I am creating a new process, which contains the net use command I wish to process. I am using the CreateProcessA function to run it, which is fine and then attempt to read in each line as it is processed. I have used this on another DOS program and it works fine, but this one does. A segment of my code is as follows:
excute_net_use is my function name and it seems to get stuck when calling the ReadFile function - I suspect this is because it gets no data it can read back and just hangs.
What I need to know is:
a) Is there any way of returning the output from a Net Use command
b) Or preferably a different way of mapping drives from the program and controlling whether it has succeeded or not.
Thanks in advance
Andrew
This is related to a previous query I had regarding embedding DOS sessions in a form, which I have realise I am probably not going to be able to do. What I need to do is the following:
- Attempt to map a drive to a remote machine (I know the user name and password)
- Determine whether or not this process has been successful and act accordingly.
At the moment, I am creating a new process, which contains the net use command I wish to process. I am using the CreateProcessA function to run it, which is fine and then attempt to read in each line as it is processed. I have used this on another DOS program and it works fine, but this one does. A segment of my code is as follows:
Code:
ReturnValue = CreateProcessA(0&, p_command_line, 0&, 0&, True, _
NORMAL_PRIORITY_CLASS, 0&, 0&, start, proc)
Do
b_success = ReadFile(hReadPipe, l_buffer, 5000, l_bytes_read, 0&)
' if some data has been returned from the application and it indicates
' a failure then we need to set the return type to indicate this failure
If (b_success = 1) Then
execute_net_use = l_buffer
Exit Function
Else
execute_net_use = "error"
Exit Function
End If
Loop Until ReturnValue <> 258
excute_net_use is my function name and it seems to get stuck when calling the ReadFile function - I suspect this is because it gets no data it can read back and just hangs.
What I need to know is:
a) Is there any way of returning the output from a Net Use command
b) Or preferably a different way of mapping drives from the program and controlling whether it has succeeded or not.
Thanks in advance
Andrew