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

Visual Studio 2015: Error C1051 - pdb file has obsolete format

$
0
0

I'm currently getting this error quite consistently for one of my projects:

"fatal error C1051: program database file, '<path_to>application.pdb', has an obsolete format, delete it and recompile"

This is on a source tree that is used just for VS2015 (I use a separate tree for VS2013 projects so there shouldn't be any binaries from any other toolchain in this tree).  My typical workflow is:

  • Clean the source tree and build: builds and links ok
  • Do a few more edit/compile cycles: all ok
  • Do another edit/compile cycle: suddenly I get error C1051

I have to then manually delete the pdb file and it will build again a few more times before it complains.  I'm using the /Debug:Fastlink pdb option.  I've compared the pdb files of a working build and one with error C1051 and the first 20k of the file is the same.

I have another VS2015 project using most of the same libraries and settings that doesn't seem to suffer from this problem.

Is there anything I can do to diagnose or fix what's going on here?


Project Dropdown Options Are Disapearing.

$
0
0

Hi Again Folks:

   Developing in Windows 10 Pro, VS 2015 Community, all C++, Win32 no MFC.

   Visual Studio 2015 Community has learned a new trick today. 

   When I created a Windows application project I could press "Project" on the VS menu bar and drop down some options. 

  

   Today, after a "Save All" I created another project. 

   When I came back to the first project the Project menu had only 3 choices.  I could no longer add items or resources, or look at the project's properties.

   I tried some different things, and after opening the project again I lost another option from the Project menu drop down. 

   In desperation, I shut down VS, logged out my account and restarted the computer.  The problem's still there. 

   I've wiped the first project out and created a new one by the same name, in case I did something weird.  The new project does the same thing.  

   What am I doing wrong?

      Thanks
      Larry




How to debug Access Violation that it thrown from windows library ucrtbase?

$
0
0

My app (java based) launches python for Windows, which, in turn, calls os.spawnv to launch another python.

From time to time I am having Access Violation exception.

00005eedb0763e68f3 ucrtbase!<lambda_7d9ee38b11181ddfdf5bd66394e53cb7>::operator()+0x1b01005eedfc763e65d9 ucrtbase!construct_environment_block<char>+0xdb02005eee14763e7aba ucrtbase!common_pack_argv_and_envp<char>+0x3103005eeebc763e778a ucrtbase!execute_command<char>+0x6204005eeee8763e8066 ucrtbase!common_spawnv<char>+0x13f05005eeef865a323d7 ucrtbase!_spawnve+0x1606005eef3865a360c6 python35!os_spawnve_impl(int mode =0n0,struct _object * path =0x03adfde0,struct _object * argv =0x03b258a0,struct _object * env =0x03b25a80)+0x1a7[c:\build\cpython\modules\posixmodule.c @5299]

I've set bp on c:\build\cpython\modules\posixmodule.c @ 5299 and here is what I see in python sources

Py_BEGIN_ALLOW_THREADS
spawnval = _spawnve(mode, path_char, argvlist, envlist);Py_END_ALLOW_THREADS

I've checked all arguments twice: they are ok. mode is 0, path_char is path to my interpeter, argvlist and envlist are both char**: NULL-terminated arrays of NULL-teminated strings.

So, it is not python fault.

I know that _spawnve is not thread safe, but there is only one thread.

I do not have sources nor private symbols for MS ucrtbase. What is the right approach to investigate it?

What is the difference between ``ucrtbased.dll`` and ``ucrtbase.dll``? 
Should I compile Python against ucrtbased.dll to find more symbols?

How to auto increase the build number in Visual C++ 2008?

VC ++ and DirectX graphics information .

$
0
0

Where can i find information about DirectX graphics with Visual C++ ?

Passing a window to a threadProc

$
0
0

Guys,

In my MFC application I'm starting a new thread:

void call()

{

CWinThread* pThread = AfxBeginThread(MyControllingFunction, /*m_hWnd*/ this);

...

}

where 'this' is  a pointer to object of class ultimately inheriting from CWnd. Somewhere, I don't remember where now, I've read that one shouldn't pass this as a argument to threadFnc but a handle (just like I show in comment /*m_hWnd*/).

So which way is the correct one? Passing this or should I pass m_hWnd?

Thank you.


One process is creating another process but I cannot get handle to it in order to kill it

$
0
0

Guys, I'm creating a process using the following:

wchar_t app_spawn[] = L"..\\vendor\\Git\\git-cmd.exe";                                //spawn the child process   if (!CreateProcess(app_spawn, NULL, NULL, NULL, TRUE, NULL,         NULL, NULL, &si, &pi))

...

And this works fine, but then I also would like to kill the spawned process. Two problems with that:

a) Terminate process returns error 6. Got that number from calling GetLastError. Don't know how can I kill this process if terminater returns error.

b) During the creation of git-cmd.exe process two processes are spawned, first one (marked with green) git-cmd.exe and second one (marked with red) a cmd.exe - this one is started by git-cmd.exe. I've checked that and run in from Explorer and indeed, starting git-cmd.exe also starts cmd.exe. Unfortunately I cannot (don't know how to)  get handle to cmd.exe in order to kill it.

Any help really appreciated.

Please see the attached png to see what I'm talking about when I say that there are two processes created.

Thank you

Visual C++ final compilation

$
0
0

What am I ought to do in order to do final compilation in Visual C++ ?


Linking windows .libs to dll with CMake and MSVC

$
0
0

I'm trying to solve an issue for two days straight now and I've searched for answer but didn't find something that helped my specific case. I inherited a Visual Studio 2008 project that creates a dll that includes some Win v7.1A SDK .libs (odbc32, odbccp32, setupapi). I want to make it a CMake project (because the project will need to be cross platform in the future) but It doesn't work. I can create a .lib file but I can't create a dll. I tried to use vcproj2cmake but it overly complicates to CMake file so I only took some of the stuff in it, I also added ideas from related questions and answers. I'm attaching my CMake, my msvc build cmd, and the error output. I checked and CMake finds all the .libs listed.

If anyone can point me in the right direction that'll be great. Thanks in advance!

Heres my CMakeLists.txt:

cmake_minimum_required(VERSION 3.2)

project(MyProj)

set(LIB_TYPE DLL)

set(OUTPUT_DIRECTORY ../BIN)

SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG "${OUTPUT_DIRECTORY}")
SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE "${OUTPUT_DIRECTORY}")
SET( CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG "${OUTPUT_DIRECTORY}")
SET( CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE "${OUTPUT_DIRECTORY}")
SET( CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG "${OUTPUT_DIRECTORY}")
SET( CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE "${OUTPUT_DIRECTORY}")


if (MSVC)
       set(CompilerFlags
           CMAKE_CXX_FLAGS
           CMAKE_CXX_FLAGS_DEBUG
           CMAKE_CXX_FLAGS_RELEASE
           CMAKE_C_FLAGS
           CMAKE_C_FLAGS_DEBUG
           CMAKE_C_FLAGS_RELEASE
       )
       foreach(CompilerFlag ${CompilerFlags})
       if(${LIB_TYPE} STREQUAL "DLL")
                string(REPLACE "/MT" "/MD" ${CompilerFlag} "${${CompilerFlag}}")
            elseif(${LIB_TYPE} STREQUAL "STAT")
                string(REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}")
            endif()
  
       endforeach()

 # SET (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
  SET (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /NODEFAULTLIB:LIBCMTD /DEF:MyProjDLL/MyProj.def")
 SET (CMAKE_STATIC_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /NODEFAULTLIB:MSVCRTD /DEF:MyProjDLL/MyProj.def")
 # SET (CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS}")
endif()



set(SOURCE 
    MyProjDLL/source/MyProj.c
)

include_directories(
    MyProjDLL/header 
    ./include 
)

#WIN SDK LIBS
link_directories(
    "C:/Program Files (x86)/Microsoft SDKs/Windows/v7.1A/Lib/x64"
)

find_library(ODBC32 odbc32 "C:/Program Files (x86)/Microsoft SDKs/Windows/v7.1A/Lib/x64")
find_library(ODBCCP32 odbccp32 "C:/Program Files (x86)/Microsoft SDKs/Windows/v7.1A/Lib/x64")
find_library(SETUP_API setupapi "C:/Program Files (x86)/Microsoft SDKs/Windows/v7.1A/Lib/x64")
MESSAGE( STATUS "ODBC32:           " ${ODBC32} )
MESSAGE( STATUS "ODBCCP32:         " ${ODBCCP32} )
MESSAGE( STATUS "SETUP_API:        " ${SETUP_API} )

set(LINK_LIBS
    ${ODBC32} ${ODBCCP32} ${SETUP_API} kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib
)


if(${LIB_TYPE} STREQUAL "DLL")
    add_library(MyProj SHARED ${SOURCE})
target_link_libraries(MyProj ${LINK_LIBS})
elseif(${LIB_TYPE} STREQUAL "STAT")
    add_library(MyProj STATIC ${SOURCE})
target_link_libraries(MyProj ${LINK_LIBS})
endif()



 #target_link_libraries(MyProj PUBLIC ${SETUP_API})
 #target_link_libraries(MyProj PRIVATE ${ODBC32})
 #target_link_libraries(MyProj PRIVATE ${ODBCCP32})

if(TARGET MyProj)

  set_property(TARGET MyProj APPEND PROPERTY COMPILE_DEFINITIONS_DEBUG
    MyProj_EXPORTS
    WIN32
    _DEBUG
    _USRDLL
    _WINDOWS
  )
endif(TARGET MyProj)
Here's my msbuild cmd:

msbuild /tv:12.0 /p:Configuration=Debug /p:Platform=Win32 /consoleloggerparameters:summary /verbosity:minimal MyProj.sln
And Here are some of the errors (I have about 45..):

MyProj.obj : error LNK2019: unresolved external symbol __imp__CreateFileA@28 referenced in function _AttachDriver 
MyProj.obj : error LNK2019: unresolved external symbol __imp__ReadFile@20 referenced in function _PostReceive 
MyProj.obj : error LNK2019: unresolved external symbol __imp__WriteFile@20 referenced in function _DoSend 
MyProj.obj : error LNK2019: unresolved external symbol __imp__CloseHandle@4 referenced in function _DoIOCTL 
MyProj.obj : error LNK2019: unresolved external symbol __imp__GetLastError@0 referenced in function _HeciCmd@32 
MSVCRTD.lib(error.obj) : error LNK2001: unresolved external symbol __imp__GetLastError@0 
MSVCRTD.lib(pdblkup.obj) : error LNK2001: unresolved external symbol __imp__GetLastError@0 
MyProj.obj : error LNK2019: unresolved external symbol __imp__SetLastError@4 referenced in function _HeciCmd@32 
MyProj.obj : error LNK2019: unresolved external symbol __imp__GetOverlappedResult@16 referenced in function _DoIOCTL 
MyProj.obj : error LNK2019: unresolved external symbol __imp__DeviceIoControl@32 referenced in function _DoIOCTL 
MSVCRTD.lib(error.obj) : error LNK2019: unresolved external symbol __imp__IsDebuggerPresent@0 referenced in function "void __cdecl failwithmessage(void *,int,int,char const *)" (?failwithmessage@@YAXPAXHHPBD@Z) 
MSVCRTD.lib(gs_report.obj) : error LNK2001: unresolved external symbol __imp__IsDebuggerPresent@0 
MSVCRTD.lib(error.obj) : error LNK2019: unresolved external symbol __imp__RaiseException@16 referenced in function "int __cdecl DebuggerProbe(unsigned long)" (?DebuggerProbe@@YAHK@Z) 
MSVCRTD.lib(error.obj) : error LNK2019: unresolved external symbol __imp__GetProcAddress@8 referenced in function "void __cdecl _RTC_AllocaFailure(void *,struct _RTC_ALLOCA_NODE *,int)" (?_RTC_AllocaFailure@@YAXPAXPAU_RTC_ALLOCA_NODE@@H@Z) 
MSVCRTD.lib(pdblkup.obj) : error LNK2001: unresolved external symbol __imp__GetProcAddress@8 
MSVCRTD.lib(error.obj) : error LNK2019: unresolved external symbol __imp__LoadLibraryExW@12 referenced in function "void __cdecl _RTC_AllocaFailure(void *,struct _RTC_ALLOCA_NODE *,int)" (?_RTC_AllocaFailure@@YAXPAXPAU_RTC_ALLOCA_NODE@@H@Z) 


Windows Variant Coercion Rules?

$
0
0

Original on SO: http://stackoverflow.com/questions/41129804/windows-variant-coercion-rules

I have a Windows VARIANT holding a BSTR with a (supposedly) numeric value.

I want to use VariantChangeType to convert this BSTR value to a VT_I4 or VT_I8 or ...

To my surprise, passing in a string value of "5.6", . being my decimal separator, the function succeeds for integer conversion, and the resultinglValor llVal value is 6! I would have expected either a conversion error, or a value of5, which is what sscanf gives me.

-->Is there any documentation for the conversion rules used by the VARIANT conversion functions?<--

I found that VariantChangeType is implemented through (e.g.) VarI4FromStr, but there is zero info wrt. the conversion rules used by this function.


Console application without the window

$
0
0

Hi All,

I want to create a console application but it should not display any window. It should work it in background.

I know in Win32 we can use CREATE_NO_WINDOW flag. But don't know how to use the same in Visual C++. 

Could you please tell me which is the equivalent Visual C++ property? I went through most of the project properties but can't find the correct one.

Thanks & Regards

Renish

ATL ActiveX Control Hang

$
0
0

Hi,

We have control(ActiveX) which used to integrate with a 3rd party Application and in few situation its hanging/freezing up.

Following is the window structure

The Parent Control and subsequent children :  ATL ActiveX -> .Net Usercontrol -> Tab Controls -> Treeviews/Textboxes etc.

We earlier also faced issue  of  our control freezing/hanging while doing tab on text boxes and fixed that up  using the WS_EX_CONTROLPARENT . Now this flag was set for both the ActiveX and the .Net UserControl.

Now at a certain client app  this  control hangs on doing ALT-TAB to switch windows and when we get back to our control its frozen with high CPU. Now the finding is if we remove the WS_EX_CONTROLPARENT from both the ActiveX and the .NET Control it doesn't occur.  Little confusing for us and we read up MSDN and  other blogs although not clear how to approach this problem.

Any pointers ?

Thanks and Regards 


CW2AEX::Init question: when does WideCharToMultiByte fail with ERROR_INSUFFICIENT_BUFFER (Visual Studio 2015 Update 2)

$
0
0

Hello, I looked into the CW2AEX::Init function and found the following code:


int nLengthW = static_cast<int>(wcslen( psz ))+1; int nLengthA = nLengthW*4; AtlConvAllocMemory(&m_psz,nLengthA,m_szBuffer,t_nBufferLength); BOOL bFailed=(0 == ::WideCharToMultiByte( nConvertCodePage, 0, psz, nLengthW, m_psz, nLengthA, NULL, NULL )); if (bFailed) { if (GetLastError()==ERROR_INSUFFICIENT_BUFFER) { nLengthA = ::WideCharToMultiByte( nConvertCodePage, 0, psz, nLengthW, NULL, 0, NULL, NULL ); ATLPREFAST_SUPPRESS(6102) AtlConvAllocMemory(&m_psz,nLengthA,m_szBuffer,t_nBufferLength); ATLPREFAST_UNSUPPRESS() bFailed=(0 == ::WideCharToMultiByte( nConvertCodePage, 0, psz, nLengthW, m_psz, nLengthA, NULL, NULL )); } } if (bFailed) { AtlConvFreeMemory(m_psz, m_szBuffer, t_nBufferLength); AtlThrowLastWin32(); }</int>
My question is in witch rare cases the first call to WideCharToMultiByte fails with an ERROR_INSUFFICIENT_BUFFER error,
can someone give me an example,

Thanks,


Andreas


Scroll window after zoom is not exact

$
0
0

I'm using zoom in my application.

Zooming the window is working fine.

No I would like to scroll my window exact to a certain point. Like where the mouse was clicked.

I already found a similar problem hier under

social.msdn.microsoft.com/Forums/en-US/ae6a2800-c4ce-442d-a5c2-7318cee3e190/scroll-window-after-zoom?forum=vcmfcatl

But I does not have any solution for the problem.

So I try it once more.

One thing is strange for me.

I'm drawing some combobox for my text. If I go to one of this combobox with a cross in it and click exact in the cross my mouse. Then I use the following code to compute the local point:

	CWindowDC dc(this);
	OnPrepareDC(&dc);
	dc.DPtoLP(lpPoints, nCount);

for this I get a result of 1920 with a zoomfactor of 1.0.

Now I change the zoomfactor to 1.1 an click on the exact same cross in the combobox. This time I get for my click and using the function 1896.

This value changes on every different zoomfactor.

As I think the local point should always be the same for exact the same point.

Does someone know from where the difference is comming?

I got the problem for scolling to a certain point after I was zooming because of the different value after using DPtoLP.

I use MM_ANISOTROPIC as mapingmode.

Thanks

Timis





MM_ANISOTROPIC

Code Analysis: CTreeCtrl::InsertItem warning

$
0
0

I am confused.

Here is my code:

hItem = m_treeHistory.InsertItem(TVIF_TEXT|TVIF_PARAM,
  strText, 0, 0, 0, 0, (LPARAM)psAssign, TVI_ROOT, NULL);

The 9th parameter is NULL. But I get this warning with code analysis:

warning C6387: '_Param_(9)' could be '0':  this does not adhere to the specification for the function 'CTreeCtrl::InsertItem'.

Yet, when I look at the help topic the examples there use NULL.

I am using Visual Studio 2017 RC.

Thanks.


Hook user open file

$
0
0

Hi,

I have a project at college where I need to let or deny access to user when he opens a file by hex signature.

I read about hooking and detours but I couldn't find how to perform the Hook and to which function.

My main concern is, How to hook when user open file with double click or enter?

What do I hook?

Can this be done with File System Filter Drivers? There is no much code examples of it.

This needs to be done on Windows 10.

I would ready appreciate any kind of help.

Thanks,

Jonathan

INT_PTR and CString::Format

$
0
0

When building with Win32 a INT_PTR variable maps to int.

When building with x64 a INT_PTR variable maps to __int64

So when I use a myString.Format(_T("..... %d ....."), i); it fails for 64 bit code analysis.

For 64 bit I should be using %I64d.

Catch 22 situation.

What is the easiest way of dealing with this?

Cannot profile a C++ command line executable

$
0
0

I have a C++ Console application I'm working on in Visual Studio Community 2015, and I'd like to profile my code to determine hotspots. Unfortuantely, although I am able to open the Performance Explorer and see options for profiling, I am unable to click the "Start" button and gather data.

I've checked the MSDN documentation and don't see anything about profiling being limited to paid versions (though I didn't check the sales page, it's possibly listed there), and I don't see any options in the solution Properties page that would enable it.

What am I missing?

embed a html in a CDialog based dialog

$
0
0

Hi,

Is it possible to embed a html page in a CDialog based dialog?  I am thinking to have a html which has some progress bars, status text ,etc.  Whenever a new situation is coming, I can update the html and then refresh the html in the dialog.  Is it possible?  Thanks for any hint or guidance.

JD

Nested Top Most windows

$
0
0

I am having SDI/MDI application where i had several level of Top most windows and the problem is as below.

1. Open a .<format> file where it will open in SDI application.

2. There is a button over it and on click of that button, a new popup screen will come and this is set to be a Top Most window. Till this its fine and even clicking on main screen, the Top Most window always on front.

3. Now on the Pop Up screen opened in the previous step, i was trying to open another screen where this has also marked as Top most window and now this is the top most window.

4. Now when i click on the main screen, the pop up screen created in step 2 was going behind the main window and the expectation was as it was created as Top Most window it shouldn't go behind the non Top most window.

The top most attribute is set through CFrameWnd::SetWindowPos()

I need help here for solving this case. 


Viewing all 15302 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>