News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Winsocket and shellexecute

Started by PsyDonia, November 22, 2008, 11:17:11 AM

Previous topic - Next topic

PsyDonia

Hello Now when I installed easycode still some prob with compiling.
So I want to try code something and need help.
First I want to use a winsocket connection to a website.
and then return true/false if it can connect or not.
where can I read about winsocket and easycode/Masm.
Or can someone help write it.
then I want to shellexecute an external app with wait to close function.
howto do that.

Ramon Sala

Follow the Iczelion examples (located in the MASM32\EXAMPLES folder). Also, you can find some very good asm stuff at the Icezelion's web site:

http://win32assembly.online.fr/


Ramon
Greetings from Catalonia

PsyDonia

Thanks.
I have some to learn now.
So thanks.
if you have more website with reading about masm32 or goasm.
that is appreciated.


So am I right to say if I want to use shell execute I need to include Shell32.inc and lib.
is there more I have to include to use it.

PsyDonia

Now I have read some.
but don´t get it to work. nothing happens when the button is pressed.
so here is my code.
to execute notepad.
should try with some simple but I´m not that good.



.Const

.Data?

.Data

strFilePath DB "c:\windows\", 0
strFileName DB "notepad.exe", 0
Open DB "open", 0
.Code


frmMainProcedure Proc Private hWnd:HWND, uMsg:ULONG, wParam:WPARAM, lParam:LPARAM
.If uMsg == WM_CREATE

Return TRUE
.ElseIf uMsg == WM_CLOSE
Invoke IsModal, hWnd
.If Eax
Invoke EndModal, hWnd, IDCANCEL
Return TRUE
.EndIf
.EndIf
Return FALSE
frmMainProcedure EndP

frmMainExecuteButton Proc Private hWnd:HWND, uMsg:ULONG, wParam:WPARAM, lParam:LPARAM

.If uMsg == WM_LBUTTONDOWN
.If wParam == MK_LBUTTON
Invoke ShellExecute, 0, Addr Open, Addr strFileName, 0, Addr strFilePath, SW_SHOW

Invoke ExitProcess, 0
.EndIf
Return TRUE
.EndIf
Return TRUE
frmMainExecuteButton EndP



I have one form that the name is frmMain
have added one button called ExecuteButton.
I have also added in Project menu and anndin include.
The shell32.in and lib
also kernel32.inc and lib
I hope this is not all wrong.

Ramon Sala

WIndows child controls (i.e. a button) send WM_COMMAND messages to its parent. In Easy Code visuals projects those WM_COMMAND messages are always sent to the main window, that is, the window containing the control. So, in your code you have to do the following (I assume the button control is named Button1, so the control ID will be IDC_FRMMAIN_BUTTON1):

frmMainProcedure Proc Private hWnd:HWND, uMsg:ULONG, wParam:WPARAM, lParam:LPARAM
   .If uMsg == WM_CREATE
      
      Return TRUE

   .ElseIf uMsg == WM_COMMAND
      LoWord wParam                  
;Gets the control ID (low word of wParam)
      .If Ax == IDC_FRMMAIN_BUTTON1   
;Is the button sending the message?
         HiWord wParam               
;Yes, so get the action (high word of wParam)
         .If Ax == BN_CLICKED         
;Has button been clicked?
            Invoke ShellExecute, 0, Addr Open, Addr strFileName, 0, Addr strFilePath, SW_SHOW
            Return TRUE
         .EndIf
      .EndIf

   .ElseIf uMsg == WM_CLOSE
      Invoke IsModal, hWnd
      .If Eax
         Invoke EndModal, hWnd, IDCANCEL
         Return TRUE
      .EndIf
   .EndIf
   Return FALSE
frmMainProcedure EndP



On the other hand, for good GoAsm stuff, visit the following webs:
    http://www.jorgon.freeserve.co.uk
    http://www.quickersoft.com/donkey

Also, have a look at the GoAsm Assembler and Tools project support forum at this web.


Ramon
Greetings from Catalonia

PsyDonia

ok thanks.
can all stuff that are called go with the command in the main proc.
But it seems that I don´t was that far away for correct code.
But as u know I just installed and start read a little yesterday.
so thnks agian for fast and good support and help.

Ramon Sala

Hi PsyDonia,

Certainly you were not so far from correct code, but take into account that your code in the button procedure was executed when the button was down (WM_LBUTTONDOWN), not when it was clicked. The control procedure can be useful for processing messages that are not sent to the parent by the WM_COMMAND message (i.e. if you want to know when the user moves the mouse over the control). If not, you better delete the control procedure.

Most of child controls events can be managed through the WM_COMMAND message, so you can delete the control procedure when no needed. The low word of wParam contains the controld ID, while the high word of wParam contains the notification message (BN_CLICKED, BN_SETFOCUS, etc. for Button controls, EN_CHANGE, EN_SETFOCUS, etc. for Edit controls, STN_CLICKED, STN_ENABLE, etc. for Static controls, and so on).

Ramon
Greetings from Catalonia