[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x

C++

57K

Solutions

24K

Contributors

C++ is an intermediate-level general-purpose programming language, not to be confused with C or C#. It was developed as a set of extensions to the C programming language to improve type-safety and add support for automatic resource management, object-orientation, generic programming, and exception handling, among other features.

Share tech news, updates, or what's on your mind.

Sign up to Post

I'm trying to set up a uncaught exception handler at process level in a
> vc++ program
> set_terminate() and set_unexpected()
> My program is multi-threaded.  I'm already able to set up my handlers in
> the main thread and catch all the exceptions thrown by the main thread.
> What I'm not able to do is to trap all the uncaught exceptions thrown by
> non-main threads.

Can you please give me sample program inside the Winmain() how to call the set_terminate() and set_unexpected()  functions and how to declare outside of the Winmain().
0
Exploring ASP.NET Core: Fundamentals
LVL 12
Exploring ASP.NET Core: Fundamentals

Learn to build web apps and services, IoT apps, and mobile backends by covering the fundamentals of ASP.NET Core and  exploring the core foundations for app libraries.

I'm trying to investigate a problem with resource files generated by Google Omaha. These resource files contain a place-holder token (%1!s!), which is substituted with branding details during the build process. There are numerous language resource files that contains string tables and this

Here is an example string: "%1!s! some arbitrary text"

Where %1!s! is a place-holder for some substitution text?

My question: is this place-holder substitution mechanism a standard part of the Windows resource file mechanism? If so, can someone please either explain how it works? Where does it get the text used to substitute the place holder? I'm assuming the place-holder works similar to place-holders in printf? If so, how does it know which text token to replace this with? If this is not a standard resource file mechanism, does anyone have a clue as to how Omaha does this during the build process?

Many thanks.

Note: I'm not looking for suggestions to use a different approach. This is how Omaha does it and I just need to understand how this works. Thank you.
0
Dear experts,

I am learning C++

I have some idea about Objects in C++

Is there an online course which can teach me 'objects' and ' Data Structures' in great detail?

Kindly suggest.
0
Hello,
There are 2 COM interfaces whose implementation is proprietary

I need to create a COM object (either in C++ or C# com server) and invoke it to use their functions from a c# client console application

How should i approach the task?

Thank you
0
Hi Team,
I want to design the global try/catch block inside the winmain() function and my application already do have __try and __except blocks (SEH mechanism).
So i want to add global try/catch block for that it will help us to catch the unhandle exceptions.
Please find the below code and give your suggestion where can i add the global try/catch block inside the winmain(..).

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int showCmd)
{
    MSG msg = { 0 };

    __try
    {
        HACCEL      hAccel;
        WNDCLASSEX  wcl = { 0 };
        char        errorText[1024];

        g_hInst = hInstance;

        /* register main window class */
        if (!RegisterClassEx(&wcl))
            return TPG_GenMessageDialog(NULL, "Error registering main window class.",
            APP_TITLE " Win32 Error", MB_ICONSTOP, SS_MSGDLGTIMEOUT);
        /* read ini file */
        /* create main window  code*/
        /* show window - showCmd overrides saved state if not SW_SHOWNORMAL */

        hAccel = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDR_ACCELERATORS));  /* ignore error */

        /* start it up! */
        if (!Startup(errorText, sizeof errorText))
        {
            Log(mtIgnore, SS_NOMCPMSG, TPG_LOGLEVEL_ERROR, errorText);
            return TPG_GenMessageDialog(g_hWnd, errorText, APP_TITLE " Startup Error", MB_ICONSTOP,
                SS_MSGDLGTIMEOUT);
        }
        while (GetMessage(&msg, NULL, 0, 0) > 0)
        {
1
I have a code in C++ which needs to be converted into VBA.

//#include <Rcpp.h>
//#include <math.h>
//#include <iostream.h>

using namespace Rcpp;
double qnormal_x,qnormal_y,qnormal_z;
double expq(double q, double w){
if(q==1.0){
return(exp(w));
}
else{
return (expl(log(1.0+(1.0-q)*w)/(1.0-q)));
}
}
double lnq(double q, double w){
if(q==1.0){
return(log(w));
}
else{
return ((exp(log(w)*(1.0-q))-1.0)/(1.0-q));
}
}
void setseed_qnormal(double v0, double z0){
qnormal_x = sqrt(1-v0*v0);
qnormal_y = v0;
qnormal_z = z0;
}
double Q8(double w, double v){
return(8*w*v*(((16.0*w*w-24.0)*w*w+10.0)*w*w-1.0));
}
double P8(double w){
return((((128.0*w*w-256.0)*w*w+160.0)*w*w-32.0)*w*w+1.0);
}
double f(double z){
return(1.0-fabs(1.0-1.99999*z));
}
void qnormal(double q){
double qq;
qnormal_y = Q8(qnormal_x,qnormal_y);
qnormal_x = P8(qnormal_x);
qq = (q+1.0)/(3.0-q);
qnormal_z = f(expq(qq,-qnormal_z*qnormal_z*0.5));
qnormal_z = sqrt(-2.0*lnq(qq,qnormal_z));
}  

// [[Rcpp::export]]
NumericVector Chaotic(int n,double q,double v0, double z0){
  double eta;
  double xi;
  NumericVector ux(n);
setseed_qnormal(v0,z0);
for(int i=0;i<n;i++){
qnormal(q);
xi = qnormal_x*qnormal_z;
eta = qnormal_y*qnormal_z;
ux[i]= xi;
}
return ux;
}

Open in new window

0
I wish I could find simple example C++ code to read a JPG file from the disk and put it in the clipboard.
Windows, MFC, VS2017.
0
could you anyone explain how we will convert c++ code to PHP ?
0
Link to the problem:

The code works fine on my own system, but while submitting shows wrong answer?

 
   #include <stdio.h>
    void main()
    {
    	int t, n, count;
    	scanf("%d", &t);
    	while(t--)
    	{
    		count=0;
    		scanf("\n%d",&n);
    		while(n>0){
    		if(n%10==4)
    		{
    			count++;
    		}
    		n=n/10;
    	}
    	printf("\n%d", count);
    	}
    }

Open in new window

0
Hi All

I have a query regarding  memory related issue I am getting in one of my web service.
I have made a service using c# which is calling C++ third party dll. While running the service I am getting below error.

"Memory gates checking failed because the free memory is less than 1%."

After going through in deep, i found that there is some memory leak issue exist in the dll.
do we have any way by which-

1. we can release the used memory by c++ dll in c#?
2. Within service or using IIS, can we put a check by which how much free memory, service is using we will get to know and then and there can do the forceful recycle?

any idea will help.

Thanks
0
Build an E-Commerce Site with Angular 5
LVL 12
Build an E-Commerce Site with Angular 5

Learn how to build an E-Commerce site with Angular 5, a JavaScript framework used by developers to build web, desktop, and mobile applications.

Hi I am trying make a deep copy of the structure below which will contain the decoded video frames and copy to a new element in a vector without each previous element being overwritten.
The structure below is being populated as the memory in debug mode is increasing as expected with each pass of the while loop.
struct YUV_Buffer
 {
mfxFrameSurface1  *mSurface;
YUV_Buffer(mfxFrameSurface1 *pBuf = { 0 })
    : mSurface(new mfxFrameSurface1[sizeof(mfxFrameSurface1)])
{
    memcpy(mSurface, pBuf, sizeof(mfxFrameSurface1));
}

YUV_Buffer(const YUV_Buffer& YuvBuf) 
 : YUV_Buffer(YuvBuf.mSurface)  
{}

YUV_Buffer& operator = (YUV_Buffer YuvBuf) {

    std::swap(mSurface, YuvBuf.mSurface);
    return *this;
}

~YUV_Buffer() {
        MSDK_SAFE_DELETE_ARRAY(mSurface);
}
  };

Open in new window

I am calling the structure and copying the elements into the vector with each iteration of the while loop "mfxFrameSurface1 pVPPSurfacesOut[nSurfIdxOut]" contains all the information regarding the decoded video frame I need to copy pVPPSurfacesOut[nSurfIdxOut] to the vector mBuffer.push_back(root) using a deep copy so the data that the pointers in the structure are pointing to are also copied but what is actually happening is the last frame processed is overwriting all previous elements in the vector. Each time the loop passes like this: I have removed the code that is decoding each frame as its no relevant I just need to work out why the elements are getting overwritten in the vector
while(1){
std::vector<YUV_Buffer> mBuffer;
YUV_Buffer root(pVPPSurfacesOut[nSurfIdxOut]);
mBuffer.push_back(root);
}

Open in new window

each iteration of the while loop populates pVPPSurfacesOut[nSurfIdxOut] structures which contain pointers with video information like height width buffersize … and the video data its self in a NV12, YUV420 colour space, I need to access each frame from the vector mBuffer but when I try to access the vector mBuffer[0]… Im getting the last frame copyed to the vector.

Regards Nigel
0
Hi I am having problems with a vector that I am populating each element from a structure but the elements seem to be getting partially over written Here is what I am drying to do
STRUCTURE
struct YUV_Buffer
{
	void *pCacheBuf;
	int frameID;
	int height;
	int width;
	YUV_Buffer() { pCacheBuf = NULL, frameID = 0, height = 0, width = 0; }
};

Open in new window

[/Constructors
        YUV_Buffer *nBuffer;
	vector<YUV_Buffer> mBuffer;

Open in new window

Implementing the vector array
Here I create a new instance of the structure from within a while loop each iteration of the loop a new video frame is passed to the structure and then added to the vector as a new element
                        YUV_Buffer *nBuffer = new YUV_Buffer();
			nBuffer->frameID = pmfxInSurface->Data.FrameOrder; // frame number
			nBuffer->width = pmfxInSurface->Info.CropW;                 // frame width
			nBuffer->height = pmfxInSurface->Info.CropH;                // frame height
                        nBuffer->pCacheBuf = pSysFrame;                                     // YUV video buffer
                        mBuffer.emplace_back(*nBuffer);                                      // add structure to vector array
                        SAFE_DELETE_ARRAY(nBuffer);                                            // delete structure

Open in new window

I then for testing that the data in the vector element is correct I do the following with OpenCV
each iteration of the while loop cnt is implemented by 1 and mBuffer[cnt].pCacheBuf) contains the video buffer data
                  cv::Mat picYV12 = cv::Mat(pmfxInSurface->Info.CropH + (pmfxInSurface->Info.CropH / 2), pmfxInSurface->Info.CropW, CV_8UC1, mBuffer[cnt].pCacheBuf);
		  cv::Mat picBGR;
		  cv::cvtColor(picYV12, picBGR, CV_YUV2RGBA_NV12);
		  cv::Mat test;
		  cv::cvtColor(picBGR, test, CV_BGRA2RGBA);
		  cv::imshow("MyVideo", test);
		  cv::waitKey(20);

Open in new window

This code works and OpenCV display the video frame in its own window perfectly my problem is I need to load all video frames into the vector array and be able to access each frame individually from the vector but what is happening is that the last element in the vector seems to be over writing all previous elements so I end up with 3000 elements in the vector all containing the last video frame buffer. It seems that its only the buffer array that is getting over written as the frame numbers are correctly assigned to each element.

I then need to call each frame from the vector in any order I wish, I have been trying to do it this way

Open in new window

0
I am trying to open a file dialog box but stumble to in to a problem.
And i al ready #include <commdlg.h>

C:\dev\test_menu/main.cpp:146: undefined reference to `GetOpenFileNameA@4'
collect2.exe: error: ld returned 1 exit status
The terminal process terminated with exit code: 1

#include <windows.h>
#include <stdio.h>
#include <commdlg.h>



void AddMenus(HWND);
void open_file(HWND);
HMENU hMenu;

int ID_Save;
int wp;


const char g_szClassName[] = "myWindowClass";

LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, LPARAM wp)
{
    
    
    switch(msg)
    {
        case WM_COMMAND:
        
        switch(wParam)

        {
            case 2:
            MessageBeep(MB_OK);
            break;

            case 3:
            open_file(hwnd);
            break;
            


            case 5:
            SendMessage(hwnd, WM_CLOSE, 0, 0);
            break;


        }


        case WM_ACTIVATE:
            AddMenus(hwnd);
            break;
        case WM_CLOSE:
            DestroyWindow(hwnd);
        break;
        case WM_DESTROY:
            PostQuitMessage(0);
        break;
        default:
        return DefWindowProc(hwnd, msg, wParam, lParam);
    }
    
    
    return 0;
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,  LPSTR lpCmdLine, int nCmdShow)
{
    WNDCLASSEX wc;
    HWND hwnd;
    MSG Msg;
   
    wc.cbSize        = sizeof(WNDCLASSEX);
    wc.style         = 0;
    wc.lpfnWndProc   = 

Open in new window

0
We would like to find a way to automatically convert an excel workbook into c++ code.
The following tool apparently does that (calc4web) however it generates a compiled .dll intead of C++ code.
We want to be able to reuse and enhance the c++ code.
Anyone used this before? Are there any other out of the box solution out there ?
If not, is there a way or a tool  to map the entire workbook so that we can follow it like a blue print and then convert it to c++
Any ideas or solutions would be very helpful
0
I create my tree using the code a bellow :
//Create my own Tree(Items + Sub Items)
BOOL CIntAccDlg::OnInitDialog()
{
      CDialogEx::OnInitDialog();
      HTREEITEM hMétrologie, hSurveillance, hHisOuverture, hHisDépassementTempérature, hHisMiseTerre, hLogResetsHis , hMetrologieLegale,hRelais, hCourbeDeCharge, hGlissProgrammé ,hHorodate, hFacturation, hStructureActive, hGlissPeriodique,hStructurePassivective, hJoursFériés, hCalendrierTarifaire, hInstantanée, hMetrologieNonLegale, hEnergie, hMoyenne,hMaximas,hContrat,hExursionTension
      , hCoupures,hCommunication, hCléAESGCM, hCléCrypAUTHGCM, hParPhyPortLocal, hHDLCPortLocal, hParPhyPortSerie, hParHDLCPortSerie, hImporter, hExporter, hImprimer;
      
      //Métrologie
      hMétrologie = m_treeCtrl.InsertItem(_T("Métrologie"), TVI_ROOT);
      hMetrologieLegale = m_treeCtrl.InsertItem(_T("Métrologie Légale"), hMétrologie);
      hMetrologieNonLegale = m_treeCtrl.InsertItem(_T("Métrologie Non Légale"), hMétrologie);
      //Métrologie légale
      hInstantanée = m_treeCtrl.InsertItem(_T("Instantanées "), hMetrologieLegale);
      hEnergie = m_treeCtrl.InsertItem(_T("Energies "), hMetrologieLegale);
      //Métrologie Non légale
      hMoyenne = m_treeCtrl.InsertItem(_T("Moyennes "), hMetrologieNonLegale);
      hMaximas = m_treeCtrl.InsertItem(_T("Maximas "), hMetrologieNonLegale);
      hContrat = m_treeCtrl.InsertItem(_T("Contrat "), hMetrologieNonLegale);
      hExursionTension = m_treeCtrl.InsertItem(_T("Excursion de tension "), hMetrologieNonLegale);
      //Relais
      hRelais= …
0
Hello ,
I create a menu "config" .I want to open another dialog box when I click in the menu "Config".
I make a function added to Menu ID : W_Command
Then I call it in the principal dialog box :InAccDlg ,as it shown in the code as bellow , while compiling ,the called dialogBox wasn't shown .
My code is as bellow :

void CIntAccDlg::OnIdrMenu1()
{
      CConfigDlg ConfigDlg;
      ConfigDlg.DoModal();
      ShowWindow(SW_SHOW);
}
Is there any problem !
0
I want to make sms app (short message) for android using c++ builder, so help me please
0
Hello everyone, is there code to create your console, can you somehow link it to using commands from a file and pressing the enter key?
c ++

    #include <log.h>
    #include <cvar.h>
    #include <option.h>
    #include <stream.h>
    #include <xmpp.h>
    #include <xmpp_kb.h>
    #include <session.h>
    #include <threads.h>
    #include <lang.h>
    #include <tools.h>

    int main(int argc, char *argv[])
    {
        const char *exe_path = argv[0];

        cvar_init();

        cvar_parse_file("kb.cfg");

        if (cvar.g_language != NULL)
        {
            char *path;

            FORMAT(path, "kfg/dang/%s.kfg", cvar.g_language);
            cvar_parse_file(path);
            free(path);
        }

        char *token = NULL;
        char *online_id = NULL;
        char *cmdline = NULL;

        option_parse(argc, argv, &token, &online_id, &cmdline);

        /* Start */

        if (isatty(STDOUT_FILENO))
        {
        }

        /* End */

        idh_init();

        XMPP_REGISTER_QUERY_HDLR();
        XMPP_WF_REGISTER_QUERY_HDLR();

        int wfs = stream_connect(cvar.online_server,
                                 cvar.online_server_port);

        if (wfs > 0)
        {
            session_init(wfs, online_id);

            threads_init();

            xmpp_connect(token, online_id);

            threads_run(exe_path, cmdline);

            threads_quit();

            xmpp_close();

0
I had this question after viewing Remote App failed to launch using MSTSCLib API.
I have to launch an application remotely. with the below lines of code able to connect remote  desktop. but not able to launch remote application
m_RemoteAppobj = m_RDPClient.get_RemoteProgram2();
m_RemoteAppobj.put_RemoteProgramMode(true);
m_RemoteAppobj.put_RemoteApplicationName(L"Notepad");
m_RemoteAppobj.put_RemoteApplicationProgram(L"C:\\Windows\\System32\\notepad.exe");
void CTestRdpNECTIDlg::OnConnectedMstscax1()
{
      try
      {
            LPCTSTR lpExecutablePath = L"C:\\Windows\\System32\\notepad.exe";
            LPCTSTR lpworkingdirectory = L"c:\\";
            int n=m_RDPClient.get_Connected();
            m_RemoteAppobj.ServerStartProgram(lpExecutablePath,L"",lpworkingdirectory,false ,L"ARGS",false );
      }
      catch(...)
      {
            wchar_t buf[256];
            memset(buf,0,sizeof(buf)/sizeof(wchar_t));
            FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
                  NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
                  buf, (sizeof(buf) / sizeof(wchar_t)), NULL);
            AfxMessageBox(buf);
      }
}
0
Bootstrap 4: Exploring New Features
LVL 12
Bootstrap 4: Exploring New Features

Learn how to use and navigate the new features included in Bootstrap 4, the most popular HTML, CSS, and JavaScript framework for developing responsive, mobile-first websites.

I have three base Classes {Player,Weapon,Game} and one inherited Class Warrior from Player.

I would like to code function addWizard using function .I thought of dymanic casting,but I'm not sure how to start. Any help would be appreciated.

Notes:

*Each index in playersArray consists of pointers to class Player.

*If a player's name in a given index,oplayersArray equals to empty string, it indicates there's no player yet.

*I added the constructors of each Class Game and Player(the default only) and Wizard.

void addWizard(string const& playerName,string const& weaponName,
                       Target target, int hitstrength,int range);

GameStatus Game::addPlayer(const string playerName, const string weaponName,
                               Target target,int hit_strength)
    {   int count=0,place=0;
        if(this->countPlayers()>=maxPlayer)
        {
            throw GameFull();
        }
        for(int i=0;i<maxPlayer;i++)
        {
            if(playersArray[i]->getPlayerName()!="" &&
               playersArray[i]->isPlayer(playerName))
            {
                throw NameAlreadyExists();
            }
            if(playersArray[i]->getPlayerName()==""&& count==0)
            {
                count++;
                place=i;
            }
        }
        Weapon newWeapon(weaponName,target,hit_strength);
        Player newPlayer(playerName,newWeapon);
        *playersArray[place]=newPlayer;
        return SUCCESS;
    } 

Open in new window


Classes:

class Game {
        int maxPlayers;
        Player **playersArray;
}

class Player {
        string player_name;
        int level;
        int strength;
        Weapon player_weapon; }

//the inherited Class 

class Wizard : public Player {
    int range;
public:
    Wizard();
    Wizard (string const& name, Weapon const& weapon, int range);
}

Open in new window

Constructs:
Game::Game(int maxPlayer)
: maxPlayer(maxPlayer),playersArray(new Player*[maxPlayer])
{
    for(int i=0;i<maxPlayer;i++)
    {
        playersArray[i]=new Player;
    }
}

Player::Player():
        level(0),life(0),strength(0),place(0),player_name()
{
}

Wizard::Wizard(string const& name, Weapon const& weapon, int range) :
        Player(name,weapon),range(range){
    if (weapon.getTarget() == LIFE){
        throw IllegalWeapon();
    }
    if(range<0)
        throw InvalidParam();
}

Open in new window

0
Hello

is there a way to set gdb filename:line_number such that the filename is a path?

thanks
0
std::function as a parrameter in delegate constructor
      i want to know why control does not goes to AB() if i passed abc(AB) in main() as control goes for initialization of i as 10 when abc(10) is passed

class abc { int i;

    std::function<void(void)>func = nullptr;
public: abc(){}
    abc(std::function<void(void)>&fb):func(fb){}

    abc(int i):i(i){}
};
void AB() { cout<< "fun_AB"; }

int main() { abc(AB); abc(10); }

Open in new window

0
Good day! I'm trying to display an image in the Picture Control in the MFC with pixel data. Tell me what's wrong.

image = new DicomImage(str);
		
		image->setMinMaxWindow();
		Uint8 *pixelData = (Uint8 *)(image->getOutputData(8));
		if (pixelData != NULL){
			int w = image->getWidth();
			int h = image->getHeight();

			HBITMAP hBitmap = NULL;

			BITMAPINFOHEADER bmih;
			bmih.biSize = sizeof(BITMAPINFOHEADER);
			bmih.biWidth = 1024;
			bmih.biHeight = -512;
			bmih.biPlanes = 1;
			bmih.biBitCount = 8;
			bmih.biCompression = BI_RGB ;
			bmih.biSizeImage = 0;
			bmih.biXPelsPerMeter = 10;
			bmih.biYPelsPerMeter = 10;
			bmih.biClrUsed = 0;
			bmih.biClrImportant = 0;

			BITMAPINFO dbmi;
			ZeroMemory(&dbmi, sizeof(dbmi));  
			dbmi.bmiHeader = bmih;
			dbmi.bmiColors[0].rgbBlue = 0;
			dbmi.bmiColors[0].rgbGreen = 0;
			dbmi.bmiColors[0].rgbRed = 0;
			dbmi.bmiColors[0].rgbReserved = 0;
			void* bits = (void*)&(pixelData[0]); 

			// Create DIB
			HDC localDC = ::GetDC(NULL);
			hBitmap = CreateDIBSection(localDC, &dbmi, DIB_RGB_COLORS, &bits, NULL, 0);
			if (hBitmap == NULL) {
				::MessageBox(NULL, __T("Could not load the desired image image"), __T("Error"), MB_OK);
				return;
			}

			unsigned char* dest = new unsigned char[w*h];
			dest =	(unsigned char*)bits;
			const unsigned char* src  = pixelData;
			for (int j=0; j<w; j++){
				for (int i=0; i<h; i++, src++){
					*dest++ = *src;
					*dest++ = *src;
					*dest++ = *src;
				}
			}	

			

Open in new window

0
Hi,
I am making a Doodle Jump game in c++ using sfml,
I started building the umlaut and decided to go with a STRATEGY pattern. I don't really know if this is the right choice.
I basically got to a point where I don't know how to continue,
please if someone could take a look at my UML and tell me what they think it will be greatly appreciated.



0
I have a DLL that is simply using some pretty common code to count files in a directory. On all our test computers, and 98% of people using it, there is no problem. But a few people experience a crash to desktop from this code. I am looking for some possibilities of why this could happen in these isolated cases.

Here is the code:
int FMSGaugeCallback::getFltPlnsInFolder(wchar_t szPath[MAX_PATH])
{
	WIN32_FIND_DATA		ffd;
	wchar_t				szFileName[MAX_PATH];
	HANDLE				hFind = INVALID_HANDLE_VALUE;
	DWORD				dwError = 0;
	wchar_t				szError[255];
	wchar_t				szDir[MAX_PATH];
	int					nLen = 0, nDir = 0, nCount = 0;

	if (!PathIsDirectory(szPath))
		return 0;

	PathAddBackslashW(szPath);
	swprintf(szDir, sizeof szDir,  L"%s*.pln", szPath);
	hFind = FindFirstFileW(szDir, &ffd);								// Open filefind
	if (INVALID_HANDLE_VALUE == hFind)								// if process fails record error
	{																// and discontinue function
		dwError = GetLastError();
		swprintf(szError, sizeof szError, ERR_SEARCH_FLT_PLNS, szPath,getLastWinError(dwError));
		writeToErrorLog(szError);
		return 0;
	}

	do																		
	{																		
		if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)					
		{
			nDir++;															// the flight plan array
		}
		else
		{//-
			nCount++;
			
		}//-
	} while (FindNextFileW(hFind, &ffd));

	FindClose(hFind);												// Close filefind
	return nCount;
}

Open in new window


It is crashing in the do while loop, not at FindFirstFile.

Any ideas?
0

C++

57K

Solutions

24K

Contributors

C++ is an intermediate-level general-purpose programming language, not to be confused with C or C#. It was developed as a set of extensions to the C programming language to improve type-safety and add support for automatic resource management, object-orientation, generic programming, and exception handling, among other features.