关于shellexeute()返回结果的问题

ljb198102 2002-11-14 09:23:53
函数:
void CSdadsDlg::OnButton1()
{
// TODO: Add your control notification handler code here
ShellExecute(this->m_hWnd,"open", "ping.exe", "", "", SW_SHOWNORMAL);

}

请问如何根据实现时ShellExecute执行ping 127.0.0.1的效果,
并根据ping 的返回结果谈出不同的消息
本人用HINSTANCE respone=ShellExecute(this->m_hWnd,"open", "ping.exe", "", "", SW_SHOWNORMAL);

if (n>32)
AfxMessageBox("success");
else
AfxMessageBox("faiL");

未能成功!!
...全文
48 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
PoolD 2002-11-16
  • 打赏
  • 举报
回复
自己写代码实现ping的功能不行吗?很多资料上都有的。
道素 2002-11-15
  • 打赏
  • 举报
回复
用getlasterror
Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, _
lpRect As RECT) As Long

Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type

Const ERROR_INVALID_WINDOW_HANDLE As Long = 1400
Const ERROR_INVALID_WINDOW_HANDLE_DESCR As String = "Invalid window handle."

Sub PrintWindowCoordinates(hwnd As Long)
' Prints left, right, top, and bottom positions of a window in pixels.

Dim rectWindow As RECT

' Pass in window handle and empty the data structure.
' If function returns 0, an error occurred.
If GetWindowRect(hwnd, rectWindow) = 0 Then
' Check LastDLLError and display a dialog box if the error
' occurred because an invalid handle was passed.
If Err.LastDllError = ERROR_INVALID_WINDOW_HANDLE Then
MsgBox ERROR_INVALID_WINDOW_HANDLE_DESCR, _
Title:="Error!"
End If
Else
Debug.Print rectWindow.Bottom
Debug.Print rectWindow.Left
Debug.Print rectWindow.Right
Debug.Print rectWindow.Top
End If
End Sub
cngxylyh 2002-11-15
  • 打赏
  • 举报
回复
不如用shell "ping.exe 127.0.0.1>>a.txt“
然后读A.TXT的内容。
papaya_stone 2002-11-14
  • 打赏
  • 举报
回复
if (respone>32)

你可以根据返回值查一下错误的原因:
Returns a value greater than 32 if successful, or an error value that is less than or equal to 32 otherwise. The following table lists the error values. The return value is cast as an HINSTANCE for backward compatibility with 16-bit Windows applications. 0 The operating system is out of memory or resources.
ERROR_FILE_NOT_FOUND The specified file was not found.
ERROR_PATH_NOT_FOUND The specified path was not found.
ERROR_BAD_FORMAT The .exe file is invalid (non-Win32® .exe or error in .exe image).
SE_ERR_ACCESSDENIED The operating system denied access to the specified file.
SE_ERR_ASSOCINCOMPLETE The file name association is incomplete or invalid.
SE_ERR_DDEBUSY The DDE transaction could not be completed because other DDE transactions were being processed.
SE_ERR_DDEFAIL The DDE transaction failed.
SE_ERR_DDETIMEOUT The DDE transaction could not be completed because the request timed out.
SE_ERR_DLLNOTFOUND The specified dynamic-link library was not found.
SE_ERR_FNF The specified file was not found.
SE_ERR_NOASSOC There is no application associated with the given file name extension.
SE_ERR_OOM There was not enough memory to complete the operation.
SE_ERR_PNF The specified path was not found.
SE_ERR_SHARE A sharing violation occurred.

15,471

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 进程/线程/DLL
社区管理员
  • 进程/线程/DLL社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧