Results 1 to 23 of 23

Thread: [RESOLVED] Shell Problem

  1. #1

    Thread Starter
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Resolved [RESOLVED] Shell Problem

    Hi all,
    I am using shell and wait api to execute some exe.But the problem is that it gives a minize,maximize and close Button.If the user Press the close button, the process get affected.Is it able to hide the close button in shell and wait function.



    Thanks in Advance

  2. #2
    Shared Member
    Join Date
    May 2005
    Location
    Kashmir, India
    Posts
    2,277

    Re: Shell Problem

    You can use RemoveMenu API to remove the Close button from the Window? Or a better way would be hide it from the User.
    Last edited by Shuja Ali; Aug 22nd, 2006 at 07:28 AM. Reason: Corrected as per JR's comments
    Use [code] source code here[/code] tags when you post source code.

    My Articles

  3. #3

    Thread Starter
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: Shell Problem

    Dear RRN78,
    I think you are wrong.Please the read the post.

  4. #4
    PowerPoster
    Join Date
    May 2006
    Posts
    2,988

    Re: Shell Problem

    remove it in your program, or the external process?

  5. #5

    Thread Starter
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: Shell Problem

    I am running a external process.;

  6. #6
    Shared Member
    Join Date
    May 2005
    Location
    Kashmir, India
    Posts
    2,277

    Re: Shell Problem

    Quote Originally Posted by danasegarane
    I am running a external process.;
    Did you take a look at my Post #3
    Use [code] source code here[/code] tags when you post source code.

    My Articles

  7. #7

    Thread Starter
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: Shell Problem

    dear Suja,
    Please give an example for that API

  8. #8
    Hyperactive Member
    Join Date
    Aug 2006
    Posts
    367

    Re: Shell Problem

    Would you like the new process to be completely hidden, or do you need it to be visible but tamperproof? Is it a windowed process, or a CMD dos app?

  9. #9

    Thread Starter
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: Shell Problem

    It will be better if you it is hidden also.

  10. #10
    Shared Member
    Join Date
    May 2005
    Location
    Kashmir, India
    Posts
    2,277

    Re: Shell Problem

    The better way would be to Hide the process from the User. And regarding your example, if you do a search here for RemoveMenu API you will get 100s of examples.

    Also check www.allapi.net
    Last edited by Shuja Ali; Aug 22nd, 2006 at 07:29 AM. Reason: Corrected as per JR's comments
    Use [code] source code here[/code] tags when you post source code.

    My Articles

  11. #11

    Thread Starter
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: Shell Problem

    Please Suggest the way of hidding the shell and wait process

  12. #12
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Shell Problem

    There is no API called RemoveSystemMenu, the name of the function is simply RemoveMenu. You just need to get the handle of the system menu first which you do with a call to GetSystemMenu. You'll need to know the hWnd of the window from which you want to remove the menu item. Since I don't know how you launch your application I can't help you with that more than that you could use FindWindow to get it. But there might be other ways depending on how you shell the app. Anyway when you know the hWnd you can use code simular to the following:
    VB Code:
    1. Private Declare Function GetSystemMenu Lib "user32.dll" ( _
    2.     ByVal hWnd As Long, _
    3.     ByVal bRevert As Long _
    4. ) As Long
    5.  
    6. Private Declare Function RemoveMenu Lib "user32.dll" ( _
    7.     ByVal hMenu As Long, _
    8.     ByVal nPosition As Long, _
    9.     ByVal wFlags As Long _
    10. ) As Long
    11.  
    12. Private Const SC_CLOSE As Long = &HF060&
    13. Private Const MF_BYCOMMAND As Long = &H0&
    14.  
    15. Public Sub RemoveClose(ByVal hWnd As Long)
    16.     'Remove the Close command from the window associated with the hWnd
    17.     'passed as the argument.
    18.     Dim hMenu As Long
    19.     hMenu = GetSystemMenu(hWnd, 0)
    20.     If hMenu Then
    21.         Call RemoveMenu(hMenu, SC_CLOSE, MF_BYCOMMAND)
    22.     End If
    23. End Sub

  13. #13
    Shared Member
    Join Date
    May 2005
    Location
    Kashmir, India
    Posts
    2,277

    Re: Shell Problem

    Quote Originally Posted by danasegarane
    It will be better if you it is hidden also.
    Then instead of using SW_SHOWNORMAL use SW_HIDE when you call ShellExecute API.
    VB Code:
    1. Public Const SW_HIDE = 0
    Use [code] source code here[/code] tags when you post source code.

    My Articles

  14. #14
    Shared Member
    Join Date
    May 2005
    Location
    Kashmir, India
    Posts
    2,277

    Re: Shell Problem

    Quote Originally Posted by Joacim Andersson
    There is no API called RemoveSystemMenu, the name of the function is simply RemoveMenu.
    I can't beleive that I have been writing RemoveSystemMenu instead of RemoveMenu.

    Thanks for correcting that.
    Use [code] source code here[/code] tags when you post source code.

    My Articles

  15. #15

    Thread Starter
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: Shell Problem

    Is there any method to run the shelled file in hidden mode.

  16. #16

  17. #17
    Hyperactive Member
    Join Date
    Aug 2006
    Posts
    367

    Re: Shell Problem

    One thing to note is that Shell() runs concurrently with the rest of your program.. It does not wait until the process finishes before executing the lines after Shell().. This link points to a more diverse routine..
    http://www.vbforums.com/showpost.php...96&postcount=8

  18. #18
    Shared Member
    Join Date
    May 2005
    Location
    Kashmir, India
    Posts
    2,277

    Re: Shell Problem

    Quote Originally Posted by danasegarane
    Is there any method to run the shelled file in hidden mode.
    Can you post the code for ShellExecute that you are using. You just have to replace SW_SHOWNORMAL with SW_HIDE.
    Use [code] source code here[/code] tags when you post source code.

    My Articles

  19. #19

    Thread Starter
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: Shell Problem

    Dear Suja,
    I am using the following code.I am using the "Exec" Portion only.I
    want to hide the shelled process.

    Shell and wait

  20. #20
    Shared Member
    Join Date
    May 2005
    Location
    Kashmir, India
    Posts
    2,277

    Re: Shell Problem

    Before calling the CreateProcess API set the dwShowWindow to 0.
    VB Code:
    1. start.wShowWindow = 0
    Use [code] source code here[/code] tags when you post source code.

    My Articles

  21. #21
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Shell Problem

    Quote Originally Posted by Shuja Ali
    Before calling the CreateProcess API set the dwShowWindow to 0.
    VB Code:
    1. start.wShowWindow = 0
    That's not enough, you also need to set the dwFlags member to STARTF_USESHOWWINDOW otherwise the wShowWindow is ignored (since you never set a value to wShowWindow it's already equal to 0). Changes shown in bold
    VB Code:
    1. Private Sub ExecCmd(CmdLine As String)
    2. [b]    Const STARTF_USESHOWWINDOW As Long = &H1 [/b]
    3.     Dim proc As PROCESS_INFORMATION
    4.     Dim start As STARTUPINFO
    5.     Dim ret As Long
    6.     ' Initialize the STARTUPINFO structure:
    7.     start.cb = Len(start)
    8. [b]    start.dwFlags = STARTF_USESHOWWINDOW [/b]
    9.     ' Start the shelled application:
    10.     ret = CreateProcessA(0&, CmdLine, 0&, 0&, 1&, NORMAL_PRIORITY_CLASS, 0&, 0&, start, proc)
    11.     ' Wait for the shelled application to finish:
    12.     ret = WaitForSingleObject(proc.hProcess, INFINITE)
    13.     ret = CloseHandle(proc.hProcess)
    14. End Sub
    Last edited by Joacim Andersson; Aug 23rd, 2006 at 08:07 AM.

  22. #22

    Thread Starter
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: Shell Problem

    Dear JA,
    Thanks for your code.I will try and will reply.

  23. #23

    Thread Starter
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: Shell Problem

    Thanks to all.My have got it.

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