Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

MFC versus winsock2.h

Posted on 2001-06-30
4
Medium Priority
?
1,501 Views
Last Modified: 2013-11-20
Hi

I am using Visual C++ 6.0
I have made a "hello world" program via the wizard
I am doing

#include "stdafx.h"
#include "resource.h"
#define WIN32_LEAN_AND_MEAN
#include <process.h>
#include <winsock2.h>



I want to use the "select file" dialog and therefore
added the code

 CString FileFilter = CString("txt files (*.txt)|*.txt")
        + CString("All files (*.*)|*.*||");

 CFileDialog FileDlg ( TRUE, NULL, NULL,
  OFN_PATHMUSTEXIST | OFN_HIDEREADONLY,
  FileFilter);

This gave the following error

:\TEMP\Byggen\SMS\SMS\SMS.cpp(380) : error C2065: 'CString' : undeclared identifier
C:\TEMP\Byggen\SMS\SMS\SMS.cpp(380) : error C2146: syntax error : missing ';' before identifier 'FileFilter'


therfore I included the

#include <afxdlgs.h>

But this gave me another problem

c:\program files\microsoft visual studio\vc98\mfc\include\afxv_w32.h(14) : fatal error C1189: #error :  WINDOWS.H already included.  MFC apps must n

but the winsock2.h do contain a #include "windows.h"


My question is

should I move over to afxdlgs.h and remove the #include "winsock2.h", if so what should I use instead.
What should I use instead of winsock2.h ?








0
Comment
Question by:kung
  • 2
4 Comments
 
LVL 12

Expert Comment

by:migel
ID: 6241254
Hi!
did you select MFC application in the wizard. Excuse me for stupped q. but it come first.
also you can directly say that your MFC APP will use WinSockets by selecting "Windows socket" check box in the 4 wizard step.
0
 
LVL 86

Accepted Solution

by:
jkr earned 900 total points
ID: 6241261
>>What should I use instead of winsock2.h ?

MFC has its own header file for windows sockets suport - try adding

#include <afxsock.h>

to your 'stdafx.h"
0
 
LVL 86

Expert Comment

by:jkr
ID: 6241262
>>#include <afxsock.h>

That's what the wizerd does when following migel's suggestion :o)
0
 

Author Comment

by:kung
ID: 6241950

That helped, thanks, however to include
#include <afx.h>
before
#include <winsock2.h>
helped aswell
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

783 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question