window has to close error

This is a discussion on window has to close error within the C++ Programming forums, part of the General Programming Boards category; I get a windows error message saying the proces has to end with this code: Code: void SendFile() { /* ...

  1. #1
    Registered User
    Join Date
    Aug 2004

    window has to close error

    I get a windows error message saying the proces has to end with this code:

    void SendFile()
    	LPOVERLAPPED overlapped;
    	overlapped->Offset = 0;
    	buffers->Head = "File";
    	buffers->HeadLength = sizeof("File");
    	MessageBox(NULL, "sdfds", "sdfsd", MB_OK);
    	HANDLE file = CreateFile("C:/Documents and Settings/Alex/Desktop/", GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, NULL);
    	if (file == INVALID_HANDLE_VALUE)
    		ApendText(textbox_status, "Error opening file");
    		ApendText(textbox_status, GetLastError());
    	if (TransmitFile(main_socket, file, NULL, NULL, NULL/*overlapped*/, buffers, NULL))
    		ApendText(textbox_status, "Transmiting file");
    		ApendText(textbox_status, "Error transmiting file");
    		ApendText(textbox_status, WSAGetLastError());
    I figured out the error is when I declare LPTRANSMIT_FILE_BUFFERS buffers and try to fill it. I'm completely loss on how this is done, if I use . instead of-> I get error during compilertion.

    If you need more info please ask.

  2. #2
    carry on JaWiB's Avatar
    Join Date
    Feb 2003
    Seattle, WA
    Generally, when windows functions want a pointer as a parameter, you pass a reference to an object. So instead of using a pointer:
    buffers.Head = "File";
    buffers.HeadLength = sizeof("File");
    TransmitFile(main_socket, file, NULL, NULL, NULL/*overlapped*/, &buffers, NULL)
    I can't guaruntee the rest of your code is right, though (never used TransmitFile)
    "Think not but that I know these things; or think
    I know them not: not therefore am I short
    Of knowing what I ought."
    -John Milton, Paradise Regained (1671)

    "Work hard and it might happen."

  3. #3
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    New York
    You could also allocate memory for your LPTRANSMIT_FILE_BUFFERS. This way, it points to availible space, which you can then assign to the appropriate variables. Then you just pass the pointer. This is an unecessary wierd way however. It's probably better just creating the regular local variable, and then passing the reference as JaWiB said.

    	TransmitFile(.., buffers, ...)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Quantum Random Bit Generator
    By shawnt in forum C++ Programming
    Replies: 62
    Last Post: 06-18-2008, 10:17 AM
  2. Avoiding Global variables
    By csonx_p in forum Windows Programming
    Replies: 32
    Last Post: 05-19-2008, 12:17 AM
  3. load gif into program
    By willc0de4food in forum Windows Programming
    Replies: 14
    Last Post: 01-11-2006, 09:43 AM
  4. Problem with Visual C++ Object-Oriented Programming Book.
    By GameGenie in forum C++ Programming
    Replies: 9
    Last Post: 08-29-2005, 11:21 PM
  5. Linking error
    By DockyD in forum C++ Programming
    Replies: 10
    Last Post: 01-20-2003, 04:27 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21