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

I just need to know how to access my PNY usb device

$
0
0

Help me access my PNY usb device


Error LNK1104: cannot open file 'mfc100d.lib'

$
0
0

Hei everyone,

I try to compile program that made for VS 2010 to VS 2013 but this error appeared.

>>Error LNK1104: cannot open file 'mfc100d.lib'

I changed the Platform toolset to VS 2010 (V100) and use shared DLL but nothing happened.

I dont have 'mfc100d.lib' but I have 'mfc100d.dll'

This is my source code: https://www.dropbox.com/sh/6i672qrbga5wecy/AACINyq2DswB3JYIHBzMkKX5a?dl=0

Hope someone coulde help me.

Thank you.

p.s: I use VS 2013 and OpenCV 3.0

Dockablepane overlap issue

$
0
0

Hi,

My dialog is of dockablepane type. The dialog will invoke normally when close the dialog through the mouse. On escape i am hiding the pane by "ShowPane(m_pDockPane,FALSE,FALSE,FALSE)". When i invoke dialog after hiding through escape , the dialog invoked will not redraw normally. DockPane will be scrambled
Please help me. Thanks in advance.

Regards,
Aishwarya

How Zoom A image Using WM_POINTER or WM_GESTURE.

$
0
0
I am totally stuck with this problem ,trying to zooming the image using WM_POINTER or WM_GESTURE.I am not using the concept of viewport.

How To block Office Macro Run fundamentally?

$
0
0

Hello. I'm Mr. Song.

I'm developing a security program.

One of this program functions, I have to block macro run in office.

I want to block that fundamentally. do not need to block UI.

(for example, as using API hook WriteFile or CreateFile to prevent file save)

To Prevent this function and all the attemps that I can.

Appreciate the help you give.

Thank you.

(Additional Information)

I'm trying to hook event and API by using detour library.

best regards

Mr Song.


How to use single CView for normal 2D drawing(drawn using CPen,Cbrush etc) and OpenGL View

$
0
0

Hi,

     I am implementing one functionality in my application using MFC vc++ vs2008. Below problem description.

I derived a class from CView and did basic drawing like rectangle ,grid and vertical ,horizontal ruler . Have to import STL 3D model from external file in this view and display it on back ground . I am sharing video where similar functionality implemented. Can you please anyone help me how it could be possible with single view. Thank you.

https://drive.google.com/open?id=0B0MUXp49k3d8T3d5NGRuVDZTejA

Regards

DNR



Division by zero when calling a C++ DLL in Excel 2010 (32-bit) VBA macro

$
0
0

Hello all,

When I call a function from a DLL, written in C++ and compiled in Visual Studio 2015 "Release" mode, I get the runtime error message “Run-time error ’11’: Division by zero” at the function call. However, when I compile as "Debug", everything runs fine.

I found out that the "Release" compilation does some name mangling with the called function, while "Debug" doesn't do that. I found the real exported name through applying "dumpbin" on the DLL. Therefore one needs to use this alias name in VBA's Declare-statement in the “Release” case (see below), while for the "Debug" compilation this is not needed. Furthermore, all this is done in a 32-bit environment (Windows 7, Office 2010), if I do that in a 64-bit environment (Windows 10, Office 365), there is no problem.

Does anybody have an idea what is going on here?


Here are the details of the problem:

The DLL “Simulation.dll” is written in C++ and compiled in Visual Studio 2015. The C++ function definition is in the file “source.cpp” which doesn’t have any header file, and reads

double __declspec(dllexport) simulationCPP18(<list of 50 parameters, all either double or double*>)

Now I compile in Visual Studio 2015 “Debug” mode to produce the DLL “Simulation.dll”. I declare the DLL function in VBA through

Declare Function simulationCPP18 _
Lib "Simulation.dll" _
(<list of 50 parameters, all double, some ByVal and some ByRef>) As Double

Running the VBA macro like this, everything works fine and the correct result is reproduced.

However, when I compile in “Release” mode, this first gives the error “Can’t find DLL entry point”. I could resolve this error, by finding out the real exported function name through applying “dumpbin” on “Simulation.dll” . This showed that the function name was mangled to “?simulationCPP18@@YGNPAN00000000N00000000000NNN00N0N00NNNNNNN@Z”. Now I used this name as function Alias in the declare statement, written as

Declare Function simulationCPP18 _
Lib "Simulation.dll" Alias “?simulationCPP18@@YGNPAN00000000N00000000000NNN00N0N00NNNNNNN@Z" _
(<list of 50 parameters, all double, some ByVal and some ByRef>) As Double

The VBA macro seems to find the entry point now, but throws the error message : “Run-time error ’11’: Division by zero” at the  point of the function call within the VBA macro, where it reads

i = simulationCPP18(<list of 50 parameters>)

Note that there is no explicit division happening at any point close to this function call, nor within the parameters.

Do you know where this different behaviour between “Debug” and “Release” compilation is coming from? Obviously, the mangled function name itself is correctly used, otherwise the Error “Can’t find DLL entry point” would prevail, right?

Thanks for any help on that.

VS2015 compilation and missing DLLs

$
0
0
I have an application that I have recently moved from VS2013 to VS2015. A user has reported an issue with Windows XP SP3. Investigation reveals that two DLLs are missing from XP SP3 with IE8, they are ieshims.dll and wer.dll.

The application is built linking to the "Multi-threaded" runtime so it should not require the VC++ runtime to be present.

The VS2013 built version of the application runs fine under XP SP3.

What changed between these two different versions of Visual Studio that could cause this? Is there some option I can use to prevent the problem?

Thanks in advance for any assistance,
Sid

Is there a file size limit to SetEndOfFile?

$
0
0

I'm using a Adaptec RAID 81605Z raid controller with 16) 2TB SanDisk drives for a total of 32TB (reported in Windows Explorer as 30.6TB) in a RAID 0 configuration. Then I try to allocate the whole drive so that I can sequentially write to it as fast as 4GB/sec for up to 2 hours of recording. I set my file pointer to close to the end of the drive and GetLastError is happy. Then when I call SetEndOfFile GetLastError reports ERROR_INVALID_PARAMETER. I then tried to back off on the allocation size and at just above 17TB it starts working.

Does anyone know if there is some limit to the size you can allocate?

Here's my code:

#include "stdafx.h"
#include <Windows.h>

int main()
{
OVERLAPPED overlapped;

HANDLE disk_file = CreateFile("D:\\Temp.Bin", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ |
FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_FLAG_NO_BUFFERING | FILE_FLAG_OVERLAPPED, NULL);
memset(&overlapped, 0, sizeof(OVERLAPPED));
overlapped.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
overlapped.Offset = 0;
overlapped.OffsetHigh = 0;

ULARGE_INTEGER ulFreeSpace;
ULARGE_INTEGER ulTotalSpace;
ULARGE_INTEGER ulTotalFreeSpace;
DWORD sectorsPerCluster;
DWORD bytesPerSector;
DWORD numberOfFreeClusters;
DWORD totalNumberOfClusters;
GetDiskFreeSpace("D:\\", &sectorsPerCluster, &bytesPerSector,
&numberOfFreeClusters, &totalNumberOfClusters);
GetDiskFreeSpaceExA("D:\\", &ulFreeSpace, &ulTotalSpace, &ulTotalFreeSpace);
ulFreeSpace.QuadPart -= 100000000000;
size_t _maxSize = ulFreeSpace.QuadPart;
_maxSize = (_maxSize / bytesPerSector) * bytesPerSector;

DWORD err = 0;
_LARGE_INTEGER pos;
pos.QuadPart = _maxSize;
SetFilePointerEx(disk_file, pos, NULL, FILE_BEGIN);
SetEndOfFile(disk_file);
err = GetLastError();
CloseHandle(disk_file);

    return 0;
}


A reproducible memory problem. May be related to __cdecl _nh_malloc_dbg_impl

$
0
0

Hi,

  I am working on a camera program in Visual C++ 2010. The program calls a function from the camera manufacturer, and that function returns the image in a char array, and put it into a Picture Control using "SendMessage". The problem is, every time the program read 9948 images, it stops. I am running it in debug mode.

  I looked at the Task Manager for the memory usage of that program, before the 9948th image, the memory increased slowly and steadily from 14000K to 18000K in about 4mins. After it reached the 9948th image, the used memory went quickly up, and came to 1827000K in roughly 2mins. 

  I checked my code and I am sure that all memory allocated by using "new" is accompanied with a "delete" after use. 

  When the memory used reached 1827000K, VS prompted a CMemoryException error message. In the back of the prompt dialogue, it pointed to a few functions and I will paste the code after the screen-shot.

  "__cdecl _nh_malloc_dbg_impl" is very new and is a stranger to me.

 ==Function 1==

extern "C" static void * __cdecl _nh_malloc_dbg_impl (

        size_t nSize,
        int nhFlag,
        int nBlockUse,
        const char * szFileName,
        int nLine,
        int * errno_tmp
        )
{
        void * pvBlk;

        for (;;)
        {
            /* do the allocation
             */
            pvBlk = _heap_alloc_dbg_impl(nSize, nBlockUse, szFileName, nLine, errno_tmp);

            if (pvBlk)
            {
                return pvBlk;
            }
            if (nhFlag == 0)
            {
                if (errno_tmp)
                {
                    *errno_tmp = ENOMEM;
                }
                return pvBlk;
            }

            /* call installed new handler */
            if (!_callnewh(nSize))
            {
                if (errno_tmp)
                {
                    *errno_tmp = ENOMEM;
                }
                return NULL;
            }

            /* new handler was successful -- try to allocate again */
        }
}

======================

== Function 2 ==

CRTIMP PFLS_GETVALUE_FUNCTION __cdecl __set_flsgetvalue()
{
#ifdef _M_IX86
    PFLS_GETVALUE_FUNCTION flsGetValue = FLS_GETVALUE;
    if (!flsGetValue)
    {
        flsGetValue = DecodePointer(gpFlsGetValue);
        TlsSetValue(__getvalueindex, flsGetValue);
    }
    return flsGetValue;
#else  /* _M_IX86 */
    return NULL;
#endif  /* _M_IX86 */
}

====================

==Function 3==

_ptiddata __cdecl _getptd_noexit (
        void
        )
{
    _ptiddata ptd;
    DWORD   TL_LastError;

    TL_LastError = GetLastError();

#ifdef _M_IX86

    /*
     * Initialize FlsGetValue function pointer in TLS by calling __set_flsgetvalue()
     */

    if ( (ptd = (__set_flsgetvalue())(__flsindex)) == NULL ) {
#else  /* _M_IX86 */
    if ( (ptd = FLS_GETVALUE(__flsindex)) == NULL ) {
#endif  /* _M_IX86 */
        /*
         * no per-thread data structure for this thread. try to create
         * one.
         */
#ifdef _DEBUG
        extern void * __cdecl _calloc_dbg_impl(size_t, size_t, int, const char *, int, int *);
        if ((ptd = _calloc_dbg_impl(1, sizeof(struct _tiddata), _CRT_BLOCK, __FILE__, __LINE__, NULL)) != NULL) {
#else  /* _DEBUG */
        if ((ptd = _calloc_crt(1, sizeof(struct _tiddata))) != NULL) {
#endif  /* _DEBUG */

            if (FLS_SETVALUE(__flsindex, (LPVOID)ptd) ) {

                /*
                 * Initialize of per-thread data
                 */

                _initptd(ptd,NULL);

                ptd->_tid = GetCurrentThreadId();
                ptd->_thandle = (uintptr_t)(-1);
            }
            else {

                /*
                 * Return NULL to indicate failure
                 */

                _free_crt(ptd);
                ptd = NULL;
            }
        }
    }

    SetLastError(TL_LastError);

    return(ptd);
}

How to draw image as any quadrilateral for an array of 4 points fast and efficiently

$
0
0
BitBlt, StretchBlt, TransparentBlt and AlphaBlend draw image as rectangle and PlgBlt draws image as parallelogram, if I give it an array of 3 POINTs, but I want to draw image as any quadrilateral for an array of 4 points fast and efficiently. How can I do that?

Why is DirectDraw (or rather Unlock) so slow on Windows 10

$
0
0

My application was created in 1997/98 and has been run on every Windows/DirectX version ever since then. The last one it worked OK on, was Windows 7/DirextX 11. When trying it on Windows 10 it seemed quite sluggish and close to unusable.

I have used Visual Studio 2015 to profile the application in order to locate the bottleneck.

While repeatedly executing an operation consisting of Lock, write to memory and Unlock for aprox 70 seconds, I found that the program spent 80% of its time in Unlock in ddraw.dll.

The OS is Windows 10 Pro, version 1511, OS Build 10586.218, 64 bits

nmake, string preprocessor definitions, and stringizing

$
0
0

In a Visual Studio build, I can add a preprocessor definition to a project and use it as a literal string by escaping its quotes:

/DVERSION=\"1.2.3\"

and in my source:

char* s = VERSION;

When I try the same thing with nmake, there are compile errors unless I use the # "stringizing" operator. Is there some trick to defining preprocessor strings in nmake? (I want to avoid changing our source files since this escaped quotes approach has been working fine on unix.)

Thanks,

Phillip

Universal Windows App in C++/CX

$
0
0

Hello,

I tried to create UWP application for Windows 10 in MS VS 2015 up3 C++/CX. If I launch it in Visual Studio

using "Start with/without debugging" my application is running ok. But if I close VisualStudio and

try to launch my application i.e. file App1.exe in Release directory I will obtain an Error Access Denied.

WHY ? how can I launch my UWP application on my computer ?I DO NOT want to sell/send it to MS Store.

Thanks

Jerry

EventLog API to Access Event Log Vew ?

$
0
0
Can i find and view all the Windows Event logs with the following API? 
What API chain should i USE ? 
Any Help Appreciated. 

API: ReadEventLog

Kind Regards, 
-B

where is recent files stored ?

$
0
0

Windows 10 ; where does it store recent Folder and Files that has been viewed ? 

Thanks 

Cloning memory?

$
0
0

C++ windows how to Clone RAM ( Memory )? using API or is there any way ? 

Any help appreciated! 

NIN_BALLOONUSERCLICK and right mouse click

$
0
0


I have a system tray icon and it has a few different tray balloons that can pop up.

In my listener for the mouse clicks I need to know if the right mouse is clicked. 
The problem is that the NIN_BALLOONUSERCLICK gets fired before the WM_RBUTTONDOWN.
I don't want the right click to kill the balloon, I only want it to popup the context menu.  Is there a way to do this?
It seems like the balloon is overtop the icon when it's launced through Shell_NotifyIcon(...), so it gets the click before the Icon does.  At the least is there a way to tell that the right click was pressed?

WndMainProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{

   if ( msg == WM_TRAYNOTIFY )
   {
	if (lParam == WM_RBUTTONUP) {
		//launches a popup menu
	}
	else if (lParam == WM_LBUTTONDBLCLK) {
		//shows a results screen
	}
	else if ( lParam == WM_RBUTTONDOWN ) {
		//does nothing yet
	}
	else if ( lParam == NIN_BALLOONUSERCLICK ) {
		//kills the balloon and launches a results screen
	}

}
Thanks in advance for the help

I can't see Makefile item type in Makefile Property Page. How do you enable it, or how do you fix it?

$
0
0

I am working with Makefile projects at the moment, and I want to specifically use Visual Studio 2015 for application development.

I started out with an Empty Project template, so I can import the existing code over. Once I have that done, and have set up the includes and library paths, the last issue remaining is building the program with the Makefile.

I did make sure the project's Property Page, under Configuration Properties > General > Configuration Type, it is set to Makefile.

However, I have noticed the Makefile isn't "detected" when building the project using CTRL+SHIFT+B (or Build...). I suspected the Makefile was not included into the Build configuration. Right-clicking on the Makefile properties gives the following image, shown below:


I cannot locate "Makefile" in the list. It is here, that I am confused, and therefore went to post my question here.

How can I set it so Visual Studio will be able to see the Makefile in my project, and then compile the project when Building the project?

Thanks.

How to implement queue, enqueue and dequeue by using two stacks, push, pop and peek?

$
0
0
As title asks, how do I implement queue, enqueue and dequeue functions by using two stacks, push, pop and peek functions?
Viewing all 15302 articles
Browse latest View live