Quantcast
Channel: Visual C forum
Viewing all 15302 articles
Browse latest View live

CFileDialog crashes after calling DoModal on Windows Server 2012 and Windows 8

$
0
0

CFileDialog crashes after calling DoModal on Windows Server 2012 and Windows 8

Below code snippet crashes in windows server 2012. It works fine on Windows 7.

TCHAR ptFiles[2048];

    ptFiles[0] =NULL;

      TCHAR tcsFilter[] =_T("XYZ Files (*.xyz)|*.xyz|All Files (*.*)|*.*||");

    CFileDialog dlg(TRUE,NULL,NULL,

                   OFN_ALLOWMULTISELECT |OFN_EXPLORER |OFN_FILEMUSTEXIST |

                   OFN_HIDEREADONLY,

                   tcsFilter,

                   NULL);

   

      TCHAR tcsTitle[] =_T("Select XYZ Files to add...");;

    dlg.m_ofn.lpstrFile = ptFiles;

    dlg.m_ofn.nMaxFile = 2048/(MAX_PATH+1);

       dlg.m_ofn.lpstrTitle = tcsTitle;

    if (dlg.DoModal()==IDOK)     à crash here

    {

}

When I collected crash dump, I found that application crashes after calling ‘ApplyOFNToShellDialog()’  at line 'HRESULT hr = (static_cast<IFileDialog*>(m_pIFileDialog))->Show(m_ofn.hwndOwner);' in DoModal() of CFileDialog.


Raman




How to set CFileDialog default file path at dlg.DoModal (in Windows 7)?

$
0
0

I found this answer in an old forum post:

CFileDialog findcpr(true, ".vtl", NULL, NULL, "cpr files (*.cpr)||All Files (*.*)||");
findcpr.m_ofn.lpstrInitialDir = m_jobdir;
findcpr.DoModal();

It works as expected under Windows XP, but not under Windows 7.

TIA.


Error in Visual C++ when trying to move all methods to the .cpp file

$
0
0

Hello, I am making a form application in C++. Going off to a good start, however, I don't like the way Microsoft's generated code has methods in the .h file. So I am moving them to the .cpp file (see link code, sry for length). But I get 2 compiler errors saying:

Error	1	error LNK2020: unresolved token (06000004) ResearchHelper.ResearchHelper::ResearchHelper_Load	C:\Users\emc2v_000\Documents\CHS-OSSD\Research Helper++\Research Helper++\Research Helper.obj	Research Helper++

And the other saying:

Error	2	error LNK1120: 1 unresolved externals	C:\Users\emc2v_000\Documents\CHS-OSSD\Research Helper++\Debug\Research Helper++.exe	Research Helper++

This is my code:

.h:

#pragma once

namespace ResearchHelper {

	using namespace System;
	using namespace System::ComponentModel;
	using namespace System::Collections;
	using namespace System::Windows::Forms;
	using namespace System::Data;
	using namespace System::Drawing;

	/// <summary>
	/// Summary for ResearchHelper
	/// </summary>
	public ref class ResearchHelper : public System::Windows::Forms::Form //class strarts here in namespace
	{
	public:
		ResearchHelper(void)
		{
			InitializeComponent();
			//
			//TODO: Add the constructor code here
			//
		}

	protected:
		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		~ResearchHelper()
		{
			if (components)
			{
				delete components;
			}
		}
	private: System::Windows::Forms::TabControl^  tabControl;
	private: System::Windows::Forms::TabPage^  LogTab;
	private: System::Windows::Forms::TabPage^  NotesTabs;
	private: System::Windows::Forms::TabPage^  EDDTab;
	private: System::Windows::Forms::TabPage^  DataTab;
	protected:

	protected:




	private: System::Windows::Forms::TabPage^  SearchTab;
	private: System::Windows::Forms::Button^  Go_btn;

	private: System::Windows::Forms::TextBox^  textBox1;
	private: System::Windows::Forms::Button^  Forward_btn;
	private: System::Windows::Forms::Button^  Backwards_btn;
	private: System::Windows::Forms::WebBrowser^  webBrowser1;


	private:
		/// <summary>
		/// Required designer variable.
		/// </summary>
		System::ComponentModel::Container ^components;

#pragma region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		void InitializeComponent(void)
		{
			System::ComponentModel::ComponentResourceManager^  resources = (gcnew System::ComponentModel::ComponentResourceManager(ResearchHelper::typeid));
			this->tabControl = (gcnew System::Windows::Forms::TabControl());
			this->LogTab = (gcnew System::Windows::Forms::TabPage());
			this->NotesTabs = (gcnew System::Windows::Forms::TabPage());
			this->EDDTab = (gcnew System::Windows::Forms::TabPage());
			this->DataTab = (gcnew System::Windows::Forms::TabPage());
			this->SearchTab = (gcnew System::Windows::Forms::TabPage());
			this->webBrowser1 = (gcnew System::Windows::Forms::WebBrowser());
			this->Backwards_btn = (gcnew System::Windows::Forms::Button());
			this->Forward_btn = (gcnew System::Windows::Forms::Button());
			this->textBox1 = (gcnew System::Windows::Forms::TextBox());
			this->Go_btn = (gcnew System::Windows::Forms::Button());
			this->tabControl->SuspendLayout();
			this->SearchTab->SuspendLayout();
			this->SuspendLayout();
			// 
			// tabControl
			// 
			this->tabControl->Controls->Add(this->EDDTab);
			this->tabControl->Controls->Add(this->LogTab);
			this->tabControl->Controls->Add(this->NotesTabs);
			this->tabControl->Controls->Add(this->DataTab);
			this->tabControl->Controls->Add(this->SearchTab);
			this->tabControl->Location = System::Drawing::Point(12, 12);
			this->tabControl->Name = L"tabControl";
			this->tabControl->SelectedIndex = 0;
			this->tabControl->Size = System::Drawing::Size(1353, 722);
			this->tabControl->TabIndex = 0;
			// 
			// LogTab
			// 
			this->LogTab->Location = System::Drawing::Point(4, 22);
			this->LogTab->Name = L"LogTab";
			this->LogTab->Padding = System::Windows::Forms::Padding(3);
			this->LogTab->Size = System::Drawing::Size(1345, 696);
			this->LogTab->TabIndex = 0;
			this->LogTab->Text = L"Log";
			this->LogTab->UseVisualStyleBackColor = true;
			// 
			// NotesTabs
			// 
			this->NotesTabs->Location = System::Drawing::Point(4, 22);
			this->NotesTabs->Name = L"NotesTabs";
			this->NotesTabs->Padding = System::Windows::Forms::Padding(3);
			this->NotesTabs->Size = System::Drawing::Size(1345, 696);
			this->NotesTabs->TabIndex = 1;
			this->NotesTabs->Text = L"Notes";
			this->NotesTabs->UseVisualStyleBackColor = true;
			// 
			// EDDTab
			// 
			this->EDDTab->Location = System::Drawing::Point(4, 22);
			this->EDDTab->Name = L"EDDTab";
			this->EDDTab->Padding = System::Windows::Forms::Padding(3);
			this->EDDTab->Size = System::Drawing::Size(1345, 696);
			this->EDDTab->TabIndex = 2;
			this->EDDTab->Text = L"EDD";
			this->EDDTab->UseVisualStyleBackColor = true;
			// 
			// DataTab
			// 
			this->DataTab->Location = System::Drawing::Point(4, 22);
			this->DataTab->Name = L"DataTab";
			this->DataTab->Padding = System::Windows::Forms::Padding(3);
			this->DataTab->Size = System::Drawing::Size(1345, 696);
			this->DataTab->TabIndex = 3;
			this->DataTab->Text = L"Data";
			this->DataTab->UseVisualStyleBackColor = true;
			// 
			// SearchTab
			// 
			this->SearchTab->Controls->Add(this->Go_btn);
			this->SearchTab->Controls->Add(this->textBox1);
			this->SearchTab->Controls->Add(this->Forward_btn);
			this->SearchTab->Controls->Add(this->Backwards_btn);
			this->SearchTab->Controls->Add(this->webBrowser1);
			this->SearchTab->Location = System::Drawing::Point(4, 22);
			this->SearchTab->Name = L"SearchTab";
			this->SearchTab->Padding = System::Windows::Forms::Padding(3);
			this->SearchTab->Size = System::Drawing::Size(1345, 696);
			this->SearchTab->TabIndex = 4;
			this->SearchTab->Text = L"Search Web";
			this->SearchTab->UseVisualStyleBackColor = true;
			// 
			// webBrowser1
			// 
			this->webBrowser1->Location = System::Drawing::Point(3, 35);
			this->webBrowser1->MinimumSize = System::Drawing::Size(20, 20);
			this->webBrowser1->Name = L"webBrowser1";
			this->webBrowser1->Size = System::Drawing::Size(1339, 661);
			this->webBrowser1->TabIndex = 0;
			this->webBrowser1->Url = (gcnew System::Uri(L"http://www.jstor.org/", System::UriKind::Absolute));
			// 
			// Backwards_btn
			// 
			this->Backwards_btn->Location = System::Drawing::Point(6, 6);
			this->Backwards_btn->Name = L"Backwards_btn";
			this->Backwards_btn->Size = System::Drawing::Size(75, 23);
			this->Backwards_btn->TabIndex = 1;
			this->Backwards_btn->Text = L"Backwards";
			this->Backwards_btn->UseVisualStyleBackColor = true;
			// 
			// Forward_btn
			// 
			this->Forward_btn->Location = System::Drawing::Point(87, 6);
			this->Forward_btn->Name = L"Forward_btn";
			this->Forward_btn->Size = System::Drawing::Size(75, 23);
			this->Forward_btn->TabIndex = 2;
			this->Forward_btn->Text = L"Forward";
			this->Forward_btn->UseVisualStyleBackColor = true;
			// 
			// textBox1
			// 
			this->textBox1->Location = System::Drawing::Point(169, 8);
			this->textBox1->Name = L"textBox1";
			this->textBox1->Size = System::Drawing::Size(1094, 20);
			this->textBox1->TabIndex = 3;
			// 
			// Go_btn
			// 
			this->Go_btn->Location = System::Drawing::Point(1269, 6);
			this->Go_btn->Name = L"Go_btn";
			this->Go_btn->Size = System::Drawing::Size(70, 23);
			this->Go_btn->TabIndex = 4;
			this->Go_btn->Text = L"Go";
			this->Go_btn->UseVisualStyleBackColor = true;
			// 
			// ResearchHelper
			// 
			this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
			this->ClientSize = System::Drawing::Size(1377, 746);
			this->Controls->Add(this->tabControl);
			this->Icon = (cli::safe_cast<System::Drawing::Icon^>(resources->GetObject(L"$this.Icon")));
			this->Name = L"ResearchHelper";
			this->Text = L"ResearchHelper";
			this->Load += gcnew System::EventHandler(this, &ResearchHelper::ResearchHelper_Load);
			this->tabControl->ResumeLayout(false);
			this->SearchTab->ResumeLayout(false);
			this->SearchTab->PerformLayout();
			this->ResumeLayout(false);

		}
#pragma endregion
	
	// here and below is in .cpp file
	private: System::Void ResearchHelper_Load(System::Object^  sender, System::EventArgs^  e);
	};
}

.cpp file:

#include "Research Helper.h"

int main()
{
	//TODO load the form 
	return 0;
}

System::Void ResearchHelper_Load(System::Object^  sender, System::EventArgs^  e){
	//TODO something at form load
}

As you can see, I am moving the method ResearchHelper_Load

error LNK2019: unresolved external symbol kinect sdk

$
0
0

Hi!

I am running Windows 7 64bit with the Kinect SDK 1.5 and developing in Visual Studio 2013. I'm receiving the message "error: LNK2019" error when I attempt to run a basic C++ Kinect program. Here is the full messageknowing that kinect10.lib is listed among the libraries in my project's properties, under Linker | Input | Additional Dependencies :

1>------ Build started: Project: projet1, Configuration: Debug Win32 ------
1>projet1.obj : error LNK2019: unresolved external symbol __imp__NuiInitialize@4 referenced in function _main
1>projet1.obj : error LNK2019: unresolved external symbol __imp__NuiShutdown@0 referenced in function _main
1>projet1.obj : error LNK2019: unresolved external symbol __imp__NuiSkeletonGetNextFrame@8 referenced in function _main
1>C:\Users\hajar\Documents\Visual Studio 2013\Projects\projet1\Debug\projet1.exe : fatal error LNK1120: 3 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Some help please!

Direct2D Example. Debug Source Code.

$
0
0

I'm going through the example here:

http://msdn.microsoft.com/en-us/library/windows/desktop/dd370994(v=vs.85).aspx

There is code:

#ifndef Assert
#if defined( DEBUG ) || defined( _DEBUG )
#define Assert(b) do {if (!(b)) {OutputDebugStringA("Assert: " #b "\n");}} while(0)
#else
#define Assert(b)
#endif //DEBUG || _DEBUG
#endif

I'm not really sure of the intended purpose of the above code or what the variable "b" actually represents in this case. I'm hoping someone will provide some explanation of the internals in this case. If I understand correctly Assert is a function that terminates the program?

Thanks for any help on this...

GWLP_USERDATA. Window User Data. Direct2D Example.

$
0
0
// Handles window messages.
LRESULT CALLBACK DemoApp::WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    LRESULT result = 0;

    if (message == WM_CREATE)
    {
        LPCREATESTRUCT pcs = (LPCREATESTRUCT)lParam;
        DemoApp *pDemoApp = (DemoApp *)pcs->lpCreateParams;

        ::SetWindowLongPtrW(
            hwnd,
            GWLP_USERDATA,
            PtrToUlong(pDemoApp)
            );

        result = 1;
    }
    else
    {
        DemoApp *pDemoApp = reinterpret_cast<DemoApp *>(static_cast<LONG_PTR>(
            ::GetWindowLongPtrW(
                hwnd,
                GWLP_USERDATA
                )));

        bool wasHandled = false;

        if (pDemoApp)
        {
            switch (message)
            {
            case WM_SIZE:
                {
                    UINT width = LOWORD(lParam);
                    UINT height = HIWORD(lParam);
                    pDemoApp->OnResize(width, height);
                }
                result = 0;
                wasHandled = true;
                break;

            case WM_DISPLAYCHANGE:
                {
                    InvalidateRect(hwnd, NULL, FALSE);
                }
                result = 0;
                wasHandled = true;
                break;

            case WM_PAINT:
                {
                    pDemoApp->OnRender();
                    ValidateRect(hwnd, NULL);
                }
                result = 0;
                wasHandled = true;
                break;

            case WM_DESTROY:
                {
                    PostQuitMessage(0);
                }
                result = 1;
                wasHandled = true;
                break;
            }
        }

        if (!wasHandled)
        {
            result = DefWindowProc(hwnd, message, wParam, lParam);
        }
    }

    return result;
}

I am studying the example code found here:

Creating a Simple Direct2D Application (Windows)

My first question is in regards to the block:

    if (message == WM_CREATE)
    {
        LPCREATESTRUCT pcs = (LPCREATESTRUCT)lParam;
        DemoApp *pDemoApp = (DemoApp *)pcs->lpCreateParams;

        ::SetWindowLongPtrW(
            hwnd,
            GWLP_USERDATA,
            PtrToUlong(pDemoApp)
            );

        result = 1;
    }

If I understand correctly if the message is WM_CREATE "lParam" is used to create a "*pDemoApp" that appears to be loaded with members that belong to "DemoApp *app" that was created in WinMain. Then "*pDemoApp" is used to set user data. I think I understand that much but I am a little unclear why this is being done.

 

        DemoApp *pDemoApp = reinterpret_cast<DemoApp *>(static_cast<LONG_PTR>(
            ::GetWindowLongPtrW(
                hwnd,
                GWLP_USERDATA
                )));

The block above if I understand correctly is used to get user data from the window. Again it is a little unclear to me why this has to be done in this way. It is also not fully clear to me what exactly user data is or why the set and get methods have to make use of a pointer.

I'm hoping to get some further explanation of the internals of the code and why it is the way that it is.

Thanks for any help on this...

Looking for documentation on linker switch /SUBSYSTEM and the minor/major version numbers

$
0
0

it's here: http://msdn.microsoft.com/en-us/library/fcc1zstk.aspx

all it has to say about the Version number is:

>> The choice of subsystem affects the entry point symbol (or entry point function) that the linker will select.
>> The optional minimum and default major and minor version numbers for the subsystems are as follows.

Where can i find a Little more Information about "affects the entry Point". ?

WM_THXADVANCE
-thomas woelfer


http://www.die.de/blog

execution time 53 VBA calling a VS c++ dll

$
0
0

Hi,

I'm building a dll that call's some other c++ library and returns the value to VBA.

I already added the directories and included the other project.Lib file. However when I call it from Vba I get execution time error 53.

I'm using 

extern "C"
{

double _stdcall Foo (...)

do somehing...

}

}

and a defFile to export my dll. Anyone can help me?

Thanks in advance


psc161 VS 2012: Snapshot Recordset no longer updatable

$
0
0

psc161(VS 2012: Snapshot Recordset no longer updatable) is solved ?

If solved means then it contains in which update ?


I am using Visual Studio Ultimate 2012 11.0.50929.0

Access Denined calling LsaGetLogonSessionData

$
0
0

Hi

I've developed a native IIS module which performs user impersonation using the LsaLogonUser.  When the application pool identity is LocalSystem, calls to LsaGetLogonSessionData succeed and I can retrieve the user name and the domain from which the token was generated.

However when the IIS application pool identity is a domain user (i.e. mydomain\someuser) who also has also been added to the "Act as part of the operating system" privilege, I get an "Access is denied" error returned from the function.

// Use the LUID member variable to determine the user name and domain that granted the kerberos ticket.
PSECURITY_LOGON_SESSION_DATA ppLogonSessionData;
NTSTATUS status = LsaGetLogonSessionData( &_logonId, &ppLogonSessionData );

if( !NT_SUCCESS( status ) ) {
	WriteTrace( L"LsaGetLogonSessionData", LsaNtStatusToWinError( status ) );
}

&_logonId is a module level variable that is populated when LsaLogonUser is executed; prior to calling LsaLogonUser I enable theSE_PRIVILEGE_ENABLED on the process token.

Does anyone have any suggestions as to which permissions are required to execute LsaGetLogonSessionData??

Thanks

[MFC]How to change the title color of the Ribbon

$
0
0

I am working on a MFC dialog environment.

How to change the title color of the CMFCRibbonBar?

Pleasehelpme.

CppUnitTestFramework: Exception in TEST_METHOD_CLEANUP hides exception in TEST_METHOD

$
0
0

In my tests, I use TEST_METHOD_CLEANUP to verify mocked calls. If an expectation is not met, an exception is thrown and I get information about that in the Test Explorer.

However, if a TEST_METHOD previously threw an exception, that output (stack trace) is hidden by the output from the exception thrown in TEST_METHOD_CLEANUP.

If the TEST_METHOD fails with an exception, is it possible for me to detect that inside TEST_METHOD_CLEANUP so that I can skip mock verification?


CppUnitTestFramework: Show message from Standard C++ exception in Test Explorer

$
0
0

If a std::exception is thrown from my code, Test Explorer will just show "Message: Unhandled C++ Exception". It does show the proper stack trace though.

Is it possible to have Test Explorer show the message from the what() method of std::exception?

error MSB6006 : "cmd.exe" exited with code 3

$
0
0

Hii

Iam migrating my application from vc++ 0.6 to vc++ 2013 , one of the error iam facing is :

error MSB6006 : "cmd.exe"  exited with code 3

Can anyone guide me through this

Thanks Ankush

Program with multiple copies of same CRT version crashes

$
0
0
I am using Visual studio 2008 on Windows 7. The project contains one file (Program.cpp). I need to enforce the usage of "Microsoft.VC90.CRT version:9.0.30729.4148" in the program execution by all the components (dlls, exe).

Program.cpp
-----------
///////////////////////////////////////////////////////////////////////
#include <Windows.h>
#include <fstream>
#include <boost/archive/binary_oarchive.hpp>

int main(int argc, char *argv[])
{
    std::ofstream ofs("test", std::fstream::binary | std::fstream::out);
    boost::archive::binary_oarchive ar(ofs);
    int x = 10;
    ar << x;
    return 0;
}
///////////////////////////////////////////////////////////////////////
Directory Structure
-------------------
Program
--------->include
---------------->boost/...<headers>
--------->lib
---------------->boost_serialization-vc90-mt-1_42.dll
---------------->boost_serialization-vc90-mt-1_42.dll.2.config
---------------->boost_serialization-vc90-mt-1_42.lib
---------------->Microsoft.VC90.CRT
--------->bin
---------------->Microsoft.VC90.CRT
--------->src
---------------->Program.cpp
--------->x64
------------ --->Release

Microsoft.VC90.CRT [version 9.0.30729.4148]
--------->Microsoft.VC90.CRT.manifest
--------->msvcm90.dll
--------->msvcp90.dll
--------->msvcr90.dll

///////////////////////////////////////////////////////////////////////
Microsoft.VC90.CRT.manifest
---------------------------
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">    <noInheritable></noInheritable>   <assemblyIdentity type="win32" name="Microsoft.VC90.CRT" version="9.0.30729.4148" processorArchitecture="amd64" ></assemblyIdentity>    <file name="msvcr90.dll" hashalg="SHA1" hash="1b065fdf0cb8516b0553128eae4af39c5f8eeb46"><asmv2:hash xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#"><dsig:Transforms><dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity"></dsig:Transform></dsig:Transforms><dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"></dsig:DigestMethod><dsig:DigestValue>Vy8CgQgbu3qH5JHTK0op4kR8114=</dsig:DigestValue></asmv2:hash></file> <file name="msvcp90.dll" hashalg="SHA1" hash="45d3027d87eade77317e92994790598c755b3920"><asmv2:hash xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#"><dsig:Transforms><dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity"></dsig:Transform></dsig:Transforms><dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"></dsig:DigestMethod><dsig:DigestValue>QTJu3Gttpt8hhCktGelNeXj4Yp8=</dsig:DigestValue></asmv2:hash></file> <file name="msvcm90.dll" hashalg="SHA1" hash="e77fd69f7c88f34329d8a95c3179f67ead330217"><asmv2:hash xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#"><dsig:Transforms><dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity"></dsig:Transform></dsig:Transforms><dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"></dsig:DigestMethod><dsig:DigestValue>1ruqF7/L+m1tqnJVscaOtNRNHIE=</dsig:DigestValue></asmv2:hash></file></assembly>

////////////////////////////////////////////////////////////////////////
boost_serialization-vc90-mt-1_42.dll is embedded with boost_serialization-vc90-mt-1_42.dll.manifest at resource 2

boost_serialization-vc90-mt-1_42.dll.manifest
---------------------------------------------
<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>
  <dependency>
    <dependentAssembly>
      <assemblyIdentity type='win32' name='Microsoft.VC90.CRT' version='9.0.30729.4148' processorArchitecture='amd64'  />
    </dependentAssembly>
  </dependency>
</assembly>

boost_serialization-vc90-mt-1_42.dll.2.config
---------------------------------------------
<configuration>
  <windows>
    <assemblyBinding xmlns='urn:schemas-microsoft-com:asm.v1'>
      <dependentAssembly>
        <assemblyIdentity type='win32' name='Microsoft.VC90.CRT' processorArchitecture='amd64' ></assemblyIdentity>
        <bindingRedirect oldVersion='0.0.0.0-9.0.30729.4148' newVersion='9.0.30729.4148'/>
      </dependentAssembly>
    </assemblyBinding>
  </windows>
</configuration>
//////////////////////////////////////////////////////////////////////

The Program.exe built using Visual Studio (in x64/Release) is embedded with the following manifest at resource 1

Program.manifest
----------------
<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>
  <dependency>
    <dependentAssembly>
      <assemblyIdentity type='win32' name='Microsoft.VC90.CRT' version='9.0.30729.4148' processorArchitecture='amd64'  />
    </dependentAssembly>
  </dependency>
</assembly>

Program.config (is prepared)
--------------
<configuration>
  <windows>
    <assemblyBinding xmlns='urn:schemas-microsoft-com:asm.v1'>
      <dependentAssembly>
        <assemblyIdentity type='win32' name='Microsoft.VC90.CRT' processorArchitecture='amd64' ></assemblyIdentity>
        <bindingRedirect oldVersion='0.0.0.0-9.0.30729.4148' newVersion='9.0.30729.4148'/>
      </dependentAssembly>
    </assemblyBinding>
  </windows>
</configuration>
////////////////////////////////////////////////////////////////////////

Program.exe and Program.config are copied to bin

Execution:
---------
1. In visual studio prompt 'path=%path%;<path to Program/lib>
2. [SCENARIO 1] Launch bin/Program.exe
--->RESULT: The program crashes in archive creation [boost::archive::binary_oarchive ar(ofs);]

[SCENARIO 2] Alternately, If I copy Program.exe and Program.config to lib and launch lib/Program.exe
--->RESULT: The program executes successfully

What is the difference between the two scenarios bin/Program.exe and lib/Program.exe? [The only difference I see is that in first scenario both boostxxxxx.dll and Program.exe use different copies of CRT dll (same version) and and in the second scenario they use the same copy] Why does it crash in the former and succeeds in the latter? How can I make it work in the first scenario?


Diff between Object Code and Binaries

$
0
0
Newbie here:

I read and hear the terms object code (.o) and binaries. Are they referring to the same files?

Thanks.

How do I write 'DoEvents' in C++?

$
0
0
My program is written in C++/CLR (but not /pure). The program is fairly involved. At the end, I call a function calledReleaseMemory() which deletes the various arrays that were initialized withnew. It turns out that when this function is called another part of the program is still executing while using some of that memory, so it bombs. Had I been writing in C# (as I usually do) I would have addedApplication.DoEvents() before trying to release memory. What C++ call will accomplish the same function? I use Windows7, VS2010. Thank you in advance.

gabriel weinreich

libmysql.lib missing and Visual C++ 2008 Express

$
0
0

Hi Mate,

I spent a lot of time to search for solution for the following problem.

I just install VC++ 2008, then try to connect to MySQL Server 5.6. I can build the application successfully. But when I run it I get an error saying that.

The program can't start because libmysql.dll is missing from your computer. Try reinstalling the program to fix this problem.

I checked the Additional Library Directories, and Additional Dependencies carefully.

Thank you very much.

Here is the code

#include <stdlib.h>
#include <iostream>
#include <sstream>
#include <stdexcept>
/* uncomment for applications that use vectors */
/*#include <vector>*/

#include "mysql_connection.h"

#include <cppconn/driver.h>
#include <cppconn/exception.h>
#include <cppconn/resultset.h>
#include <cppconn/statement.h>
#include <cppconn/prepared_statement.h>

#define EXAMPLE_HOST "127.0.0.1"
#define EXAMPLE_USER "vfarunner"
#define EXAMPLE_PASS "vfm123$%^"
#define EXAMPLE_DB "wh"

using namespace std;

int main(int argc, const char **argv)
{
  string url(argc >= 2 ? argv[1] : EXAMPLE_HOST);
  const string user(argc >= 3 ? argv[2] : EXAMPLE_USER);
  const string pass(argc >= 4 ? argv[3] : EXAMPLE_PASS);
  const string database(argc >= 5 ? argv[4] : EXAMPLE_DB);

  cout << "Connector/C++ tutorial framework..." << endl;
  cout << endl;
  cin.get();

  try {

    sql::Driver* driver = get_driver_instance();
std::auto_ptr<sql::Connection> con(driver->connect(url, user, pass));
con->setSchema(database);
std::auto_ptr<sql::Statement> stmt(con->createStatement());

// We need not check the return value explicitly. If it indicates
// an error, Connector/C++ generates an exception.
stmt->execute("CALL add_country('ATL', 'Atlantis', 'North America')");

  } catch (sql::SQLException &e) {
    /*
      MySQL Connector/C++ throws three different exceptions:

      - sql::MethodNotImplementedException (derived from sql::SQLException)
      - sql::InvalidArgumentException (derived from sql::SQLException)
      - sql::SQLException (derived from std::runtime_error)
    */
    cout << "# ERR: SQLException in " << __FILE__;
    cout << "(" << __FUNCTION__ << ") on line " << __LINE__ << endl;
    /* what() (derived from std::runtime_error) fetches error message */
    cout << "# ERR: " << e.what();
    cout << " (MySQL error code: " << e.getErrorCode();
    cout << ", SQLState: " << e.getSQLState() << " )" << endl;

    return EXIT_FAILURE;
  }

  cout << "Done." << endl;
  return EXIT_SUCCESS;
}

Upgrading projects using VBA SDK from VS2012 to VS2013

$
0
0

I am upgrading my VS2012 VC++ projects to VS2013. I have linker issues when I am building my project. I get this output from VS2013 :

error LNK2020: unresolved token (0A003F67) IID_IApcDualSite
error LNK2001: unresolved external symbol IID_IApcDualSite
error LNK2019: unresolved external symbol "void __cdecl MSAPC::ApcOleTermOrFreeLib(int,int)"(?ApcOleTermOrFreeLib@MSAPC@@YAXHH@Z) referenced infunction"public: int __cdecl MSAPC::CApcApplication<class CEspritApp,class CWinApp>::ApcOleInit(void)"(?ApcOleInit@?$CApcApplication@VCEspritApp@@VCWinApp@@@MSAPC@@QEAAHXZ)
error LNK2001: unresolved external symbol "struct MSAPC::IApc * MSAPC::g_pApcHost"(?g_pApcHost@MSAPC@@3PEAUIApc@1@EA)

Those errors doesn't rise with VS2012. Those variables and methods are defined in "ApcDual.h" and "ApcMfc.h" which are parts of VBA SDK.

Does someone know if there is an issue with VBA and VS2013 ?

Write on Cells with Excel 2010 on Windows 7 (64bits)

$
0
0

Hello,

I am trying to write on excel 2010 cells.

Here is my code:

// excel automation console app.cpp : main project file.

#include "stdafx.h"


#include "stdafx.h"


#import "C:\Program Files (x86)\Common Files\microsoft shared\OFFICE14\MSO.DLL" no_implementation rename("RGB", "ExclRGB") rename("DocumentProperties", "ExclDocumentProperties") rename("SearchPath", "ExclSearchPath")


#import "C:\Program Files (x86)\Common Files\microsoft shared\VBA\VBA6\VBE6EXT.OLB" no_implementation

#import "C:\Program Files (x86)\Microsoft Office\Office14\EXCEL.EXE" rename("DialogBox", "ExclDialogBox") rename("RGB", "ExclRGB") rename("CopyFile", "ExclCopyFile") rename("ReplaceText", "ExclReplaceText")


#include <stdexcept>

#include <iostream>

#include <windows.h>
#include <iostream>
#include <fstream>
#include <string>
#include <cstdlib>

#include <vcclr.h>

using namespace std;

using namespace Excel;

using namespace Office;

using namespace VBIDE;



int main()  
{  
    HRESULT hr = CoInitializeEx(0, COINIT_MULTITHREADED);   
    if (FAILED(hr))   
    {  
       // cout << "Failed to initialize COM library. Error code = 0x"  
        //   << hex << hr << endl;   
        //return hr;  
    }  
    // Create Excel Application Object pointer  
    Excel::_ApplicationPtr pXL;  
    if ( FAILED( pXL.CreateInstance( "Excel.Application" ) ) )  
    {  
       // cout << "Failed to initialize Excel::_Application!" << endl;  
        //return 0;  
    }  



/////////////////////////////////////////////////////////////////////////////

	string path = "C:\\Users\\test";
	string searchPattern = "*.xls";
	string fullSearchPath = path + searchPattern;

	WIN32_FIND_DATA FindData;
	HANDLE hFind;

	hFind = FindFirstFile( fullSearchPath.c_str(), &FindData );

	if( hFind == INVALID_HANDLE_VALUE )
	{
		//cout << "Error searching directory\n";
//		return -1;
	}

	do
	{
		string filePath = path + FindData.cFileName;

		pXL->Visible[0] = true;
		pXL->Visible[1] = true;

		// Open the Excel Workbook, but don't make it visible  
		pXL->Workbooks->Open(  filePath.c_str() );  

		



	

		// Access Excel Worksheet and return pointer to Worksheet cells  
        Excel::_WorksheetPtr pWksheet = pXL->ActiveSheet;  
        Excel::RangePtr pRange = pWksheet->Cells;  

		 // Read an Excel data cell. (Note Excel cells start from index = 1)  
       // double value = pRange->Item[1][1];  


		   // Write/modify Excel data cells + save. (reopen xls file to verify)  


	pRange->Item[6][3]  = "TEST";



	
    pWksheet->SaveAs(filePath.c_str()); 
		//ifstream in( filePath.c_str() );
		//if( in )
		//{
			// do stuff with the file here
		//}
		//else
		{
		//	cout << "Problem opening file " << FindData.cFileName << "\n";
		}
	}
	while( FindNextFile(hFind, &FindData) > 0 );

	if( GetLastError() != ERROR_NO_MORE_FILES )
	{
	//	cout << "Something went wrong during searching\n";
	}

  pXL->Quit();   	
/////////////////////////////////////////////////////////////////////////////      

  
    return 0;  
}


Every time my program want to open excel it crash and give me this error:

HERE : pXL->Workbooks->Open(  filePath.c_str() );  

System.Runtime.InteropServices.SEHException (0x80004005): External component has thrown an exception.
   at _com_issue_errorex(Int32 , IUnknown* , _GUID* )
   at Excel.Workbooks.Open(Workbooks* , _com_ptr_t<_com_IIID<Excel::_Workbook\,\&_GUID_000208da_0000_0000_c000_000000000046> >* , _bstr_t* Filename, _variant_t* UpdateLinks, _variant_t* ReadOnly, _variant_t* Format, _variant_t* Password, _variant_t* WriteResPassword, _variant_t* IgnoreReadOnlyRecommended, _variant_t* Origin, _variant_t* Delimiter, _variant_t* Editable, _variant_t* Notify, _variant_t* Converter, _variant_t* AddToMru, _variant_t* Local, _variant_t* CorruptLoad, Int32 lcid)

The program seems to work great on Windows XP, but i did not find any solution on the internet from now for windows 7.

Tried to add on : C:\Windows\SysWOW64\config  , a folder call Desktop, some people solved this problem doing that, but nothing for me.

Also tried to put all file attributes to normal in the folder before opening, still northing.

Is there a Excel protection , blocking the  writing from an oher program?

Viewing all 15302 articles
Browse latest View live