Has anybody out there done written a C program to send a file and receive
its periodic status callbacks. I get the file to begin transferring using
the code below using the WSFTP_SendFileThread command but I do not receive
the status callbacks defined in the programmer's guide and get an invalid
handle exception fault before the file finishes its transfer.

suggestions and/or insight would be greatly appreciated.

thanks,
eden 


#include "stdafx.h"
#include "wsftpdll.h"
#include "stdio.h"

LPCINFO pCInfo;
HWND            hWndEden;


bool FTPnow () 
{
        int nPort =21;

        pCInfo = WSFTP_InitCINFO(hWndEden, NULL, WM_USER+321,
WSFTPF_INITWINSOCK);
        pCInfo->nHostType=HOST_TYPE_AUTO;

        int nRes = WSFTP_ConnectAsync(pCInfo,"WCAEB180400-U2R"
,LOWORD(nPort),
                  "anonymous","[EMAIL PROTECTED]",WM_USER+325);

        return TRUE;
}

LONG WINAPI MessageProc(HWND h_wnd, UINT wMsg, WPARAM wParam, LPARAM lParam)
{
        LONG ret = 0;   
        switch( wMsg )
        {
                case WM_USER+321:
                {

                        printf("WSFTP_InitCINFO: wParam %d, lParam %d, Msg:
%s, Line: %s\n",
                                wParam, lParam, pCInfo->pLastMsg,
pCInfo->pLastLine);

                        DWORD i = wParam;
                }
                break;

                case WM_USER+325:
                {

                        printf("WSFTP_ConnectAsync: wParam %d, lParam %d,
Msg: %s, Line: %s\n",
                                wParam, lParam, pCInfo->pLastMsg,
pCInfo->pLastLine);
                        int nRes = WSFTP_SendCommandAsync(pCInfo,"CWD
EdenFTPFolder",WM_USER+330);
                }
                break;

                case WM_USER+322:
                {

                        printf("WSFTP_SendFileThread: wParam %d, lParam %d,
Msg: %s, Line: %s\n",
                                wParam, lParam, pCInfo->pLastMsg,
pCInfo->pLastLine);
                        
                        WSFTP_CloseConnect(pCInfo, WSFTPF_INITWINSOCK);
                        WSFTP_FreeCINFO(pCInfo);
                }
                break;

                case WM_USER+330:
                {
                        printf("WSFTP_SendCommandAsync: wParam %d, lParam
%d, Msg: %s, Line: %s\n",
                                wParam, lParam, pCInfo->pLastMsg,
pCInfo->pLastLine);
                        int nRes =
WSFTP_SendFileThread(pCInfo,"c:\\wug_tim.exe" ,"wug_tim.exe" ,true
,WM_USER+322);
                }
                break;

                case WM_USER+500:
                {
                        FTPnow();
                }
                break;

                default:
                        DefWindowProc (h_wnd, wMsg, wParam, lParam);
        }

        return 1;
}


int main(int argc, char* argv[])
{

        WNDCLASS    wndclass;
        HINSTANCE       hInstance = GetModuleHandle(NULL);

   /* Register the frame class */
        wndclass.style         = 0;
        wndclass.lpfnWndProc   = (WNDPROC) MessageProc;
        wndclass.cbClsExtra    = 0;
        wndclass.cbWndExtra    = 0;
        wndclass.hInstance     = hInstance;
        wndclass.hIcon         = NULL;
        wndclass.hCursor       = NULL;
        wndclass.hbrBackground = NULL;
        wndclass.lpszMenuName  = NULL;
        wndclass.lpszClassName = "FTPprototype";

        RegisterClass (&wndclass);
   
        hWndEden= CreateWindow( wndclass.lpszClassName,
                       (LPTSTR) NULL,
                       WS_MAXIMIZE, 
                       0, 0,
                       CW_USEDEFAULT, CW_USEDEFAULT,
                       HWND_MESSAGE, //a message-only window
                       (HMENU) NULL,
                       wndclass.hInstance,
                       (LPVOID) NULL ); //pass my this pointer which would
be added to the window data
        if (!hWndEden)
                return 0;

        ::PostMessage(hWndEden,WM_USER+500,0,0);        

        MSG msg;

        while( GetMessage( &msg, NULL, 0, 0 ) )
        { 
                TranslateMessage(&msg); 
                DispatchMessage(&msg); 
        }

        return 1;
}


Eden (Ron) Burton
Application Developer
Imagemark Solutions Development

NCR Canada, 580 Weber Street North
Waterloo, Ontario N2J 4G5
*(519) 884-1710 x5278
* [EMAIL PROTECTED]


 <<Burton, Eden.vcf>> 

Burton, Eden.vcf

Reply via email to