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

why does the order of this #includes matter

$
0
0

  please can some tell me why #include "Sales_item.h" #include<iostream> wouldn't compile, but #include<iostream> #include "Sales_item.h" compiles. the same, but different order.
it gave me 3 errors

    1) Severity Code Description Project File Line
    Error (active)  linkage specification is incompatible with previous "lround" (declared at line 76 of "c:\Users\evan_2\Documents\Visual Studio 2015\Projects\ConsoleApplication1\ConsoleApplication1\Version_test.h") ConsoleApplication1 c:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xtgmath.h 201

    2) Severity Code Description Project File Line
    Error C2375 'lround': redefinition; different linkage ConsoleApplication1 c:\program files (x86)\windows kits\10\include\10.0.10150.0\ucrt\math.h 509

    3) Severity Code Description Project File Line
    Error (active)  linkage specification is incompatible with previous "lround" (declared at line 76 of "c:\Users\evan_2\Documents\Visual Studio 2015\Projects\ConsoleApplication1\ConsoleApplication1\Version_test.h") ConsoleApplication1 c:\Program Files (x86)\Windows Kits\10\Include\10.0.10150.0\ucrt\math.h 509



    // THIS IS THE MAIN CODE:

    #include "stdafx.h"

    #include "Sales_item.h"
    #include<iostream>



    int main()
    {
     Sales_item item1;

     int x{}, y{}, z{};

     std::string isbn1{ "0-201-78345-X" }, isbn2{ "0-201-70353-X" };

     while (std::cin >> item1)
     {
      if (item1.isbn() == isbn1)
      {
       ++x;
      }
      else if (item1.isbn() == isbn2)
      {
       ++y;
      }
      else {
       ++z;
      }
     }

     std::cout << "0-201-78345-X :" << x << std::endl;
     std::cout << "0-201-70535-X :" << y << std::endl;
     std::cout << "0-201-78645-X :" << z << std::endl;
     return 0;
    }



    // THE SALES_ITEM.H CODE:

    #pragma once

    /*
    * This file contains code from "C++ Primer, Fifth Edition", by Stanley B.
    * Lippman, Josee Lajoie, and Barbara E. Moo, and is covered under the
    * copyright and warranty notices given in that book:
    *
    * "Copyright (c) 2013 by Objectwrite, Inc., Josee Lajoie, and Barbara E. Moo."
    *
    *
    * "The authors and publisher have taken care in the preparation of this book,
    * but make no expressed or implied warranty of any kind and assume no
    * responsibility for errors or omissions. No liability is assumed for
    * incidental or consequential damages in connection with or arising out of the
    * use of the information or programs contained herein."
    *
    * Permission is granted for this code to be used for educational purposes in
    * association with the book, given proper citation if and when posted or
    * reproduced.Any commercial use of this code requires the explicit written
    * permission of the publisher, Addison-Wesley Professional, a division of
    * Pearson Education, Inc. Send your request for permission, stating clearly
    * what code you would like to use, and in what specific way, to the following
    * address:
    *
    *     Pearson Education, Inc.
    *     Rights and Permissions Department
    *     One Lake Street
    *     Upper Saddle River, NJ  07458
    *     Fax: (201) 236-3290
    */

    /* This file defines the Sales_item class used in chapter 1.
    * The code used in this file will be explained in
    * Chapter 7 (Classes) and Chapter 14 (Overloaded Operators)
    * Readers shouldn't try to understand the code in this file
    * until they have read those chapters.
    */

    #ifndef SALESITEM_H
    // we're here only if SALESITEM_H has not yet been defined
    #define SALESITEM_H

    #include "Version_test.h"

    // Definition of Sales_item class and related functions goes here
    #include <iostream>
    #include <string>

    class Sales_item {
     // these declarations are explained section 7.2.1, p. 270
     // and in chapter 14, pages 557, 558, 561
     friend std::istream& operator>>(std::istream&, Sales_item&);
     friend std::ostream& operator<<(std::ostream&, const Sales_item&);
     friend bool operator<(const Sales_item&, const Sales_item&);
     friend bool
      operator==(const Sales_item&, const Sales_item&);
    public:
     // constructors are explained in section 7.1.4, pages 262 - 265
     // default constructor needed to initialize members of built-in type
    #if defined(IN_CLASS_INITS) && defined(DEFAULT_FCNS)
     Sales_item() = default;
    #else
     Sales_item() : units_sold(0), revenue(0.0) { }
    #endif
     Sales_item(const std::string &book) :
      bookNo(book), units_sold(0), revenue(0.0) { }
     Sales_item(std::istream &is) { is >> *this; }
    public:
     // operations on Sales_item objects
     // member binary operator: left-hand operand bound to implicit this pointer
     Sales_item& operator+=(const Sales_item&);

     // operations on Sales_item objects
     std::string isbn() const { return bookNo; }
     double avg_price() const;
     // private members as before
    private:
     std::string bookNo;      // implicitly initialized to the empty string
    #ifdef IN_CLASS_INITS
     unsigned units_sold = 0; // explicitly initialized
     double revenue = 0.0;
    #else
     unsigned units_sold;
     double revenue;
    #endif
    };

    // used in chapter 10
    inline
    bool compareIsbn(const Sales_item &lhs, const Sales_item &rhs)
    {
     return lhs.isbn() == rhs.isbn();
    }

    // nonmember binary operator: must declare a parameter for each operand
    Sales_item operator+(const Sales_item&, const Sales_item&);

    inline bool
    operator==(const Sales_item &lhs, const Sales_item &rhs)
    {
     // must be made a friend of Sales_item
     return lhs.units_sold == rhs.units_sold &&
      lhs.revenue == rhs.revenue &&
      lhs.isbn() == rhs.isbn();
    }

    inline bool
    operator!=(const Sales_item &lhs, const Sales_item &rhs)
    {
     return !(lhs == rhs); // != defined in terms of operator==
    }

    // assumes that both objects refer to the same ISBN
    Sales_item& Sales_item::operator+=(const Sales_item& rhs)
    {
     units_sold += rhs.units_sold;
     revenue += rhs.revenue;
     return *this;
    }

    // assumes that both objects refer to the same ISBN
    Sales_item
    operator+(const Sales_item& lhs, const Sales_item& rhs)
    {
     Sales_item ret(lhs);  // copy (|lhs|) into a local object that we'll return
     ret += rhs;           // add in the contents of (|rhs|)
     return ret;           // return (|ret|) by value
    }

    std::istream&
    operator>>(std::istream& in, Sales_item& s)
    {
     double price;
     in >> s.bookNo >> s.units_sold >> price;
     // check that the inputs succeeded
     if (in)
      s.revenue = s.units_sold * price;
     else
      s = Sales_item();  // input failed: reset object to default state
     return in;
    }

    std::ostream&
    operator<<(std::ostream& out, const Sales_item& s)
    {
     out << s.isbn() << " " << s.units_sold << " "
      << s.revenue << " " << s.avg_price();
     return out;
    }

    double Sales_item::avg_price() const
    {
     if (units_sold)
      return revenue / units_sold;
     else
      return 0;
    }
    #endif


// THE VERSION_TEST.H CODE:

    #pragma once

    /*
    * This file contains code from "C++ Primer, Fifth Edition", by Stanley B.
    * Lippman, Josee Lajoie, and Barbara E. Moo, and is covered under the
    * copyright and warranty notices given in that book:
    *
    * "Copyright (c) 2013 by Objectwrite, Inc., Josee Lajoie, and Barbara E. Moo."
    *
    *
    * "The authors and publisher have taken care in the preparation of this book,
    * but make no expressed or implied warranty of any kind and assume no
    * responsibility for errors or omissions. No liability is assumed for
    * incidental or consequential damages in connection with or arising out of the
    * use of the information or programs contained herein."
    *
    * Permission is granted for this code to be used for educational purposes in
    * association with the book, given proper citation if and when posted or
    * reproduced. Any commercial use of this code requires the explicit written
    * permission of the publisher, Addison-Wesley Professional, a division of
    * Pearson Education, Inc. Send your request for permission, stating clearly
    * what code you would like to use, and in what specific way, to the following
    * address:
    *
    *  Pearson Education, Inc.
    *  Rights and Permissions Department
    *  One Lake Street
    *  Upper Saddle River, NJ  07458
    *  Fax: (201) 236-3290
    */

    #ifndef VERSION_TEST_H
    #define VERSION_TEST_H

    /* As of the first printing of C++ Primer, 5th Edition (July 2012),
    * the Microsoft Complier did not yet support a number of C++ 11 features.
    *
    * The code we distribute contains both normal C++ code and
    * workarounds for missing features.  We use a series of CPP variables to
    * determine whether a given features is implemented in a given release
    * of the MS compiler.  The base version we used to test the code in the book
    * is Compiler Version 17.00.50522.1 for x86.
    *
    * When new releases are available we will update this file which will
    * #define the features implemented in that release.
    */

    #if _MSC_FULL_VER == 170050522 || _MSC_FULL_VER == 170050727
    // base version, future releases will #define those features as they are
    // implemented by Microsoft

    /* Code in this delivery use the following variables to control compilation

    Variable tests           C++ 11 Feature
    CONSTEXPR_VARS            constexpr variables
    CONSTEXPR_FCNS            constexpr functions
    CONSTEXPR_CTORS           constexpr constructors and other member functions
    DEFAULT_FCNS              = default
    DELETED_FCNS              = delete
    FUNC_CPP                  __func__ local static
    FUNCTION_PTRMEM           function template with pointer to member function
    IN_CLASS_INITS            in class initializers
    INITIALIZER_LIST          library initializer_list<T> template
    LIST_INIT                 list initialization of ordinary variables
    LROUND                    lround function in cmath
    NOEXCEPT                  noexcept specifier and noexcept operator
    SIZEOF_MEMBER             sizeof class_name::member_name
    TEMPLATE_FCN_DEFAULT_ARGS default template arguments for function templates
    TYPE_ALIAS_DECLS          type alias declarations
    UNION_CLASS_MEMS          unions members that have constructors or copy control
    VARIADICS                 variadic templates
    */
    #endif  // ends compiler version check

    #ifndef LROUND
    inline long lround(double d)
    {
     return (d >= 0) ? long(d + 0.5) : long(d - 0.5);
    }
    #endif

    #endif  // ends header guard

                                                                                                                                                                               


Converting a JPG to BMP in GdiPlus

$
0
0

I'm trying to translate my 32-bit PB code for converting JPGs to BMP files to 64-bit C++ and it doesn't want to work.  It's not reporting any errors, just never gets past the Save->

I put notes in the code below showing where it gets to and where it never gets to

Any ideas?

INT getencoderclsid(const WCHAR* format,CLSID* pClsid)
{
     UINT  num = 0;          // number of image encoders
     UINT  size = 0;         // size of the image encoder array in bytes

     Gdiplus::ImageCodecInfo* pImageCodecInfo = NULL;
     Gdiplus::GetImageEncodersSize(&num, &size);

     if(size == 0)
       return -1;  // Failure

     pImageCodecInfo=(Gdiplus::ImageCodecInfo*)(malloc(size));

     if(pImageCodecInfo == NULL)
       return -1;  // Failure

     GetImageEncoders(num, size, pImageCodecInfo);

     for(UINT j = 0; j < num; ++j)
     {
       if( wcscmp(pImageCodecInfo[j].MimeType, format) == 0 )
       {
         *pClsid = pImageCodecInfo[j].Clsid;
         free(pImageCodecInfo);
         return j;  // Success
       }    
     }

     free(pImageCodecInfo);
     return -1;  // Failure
}

BOOL convertimage(std::string loadflname,std::string saveflname,std::string smimetype)
{
     std::string b;
     std::wstring wtxt;
     BOOL retval;
     ULONG_PTR hgdiplus;
     Gdiplus::GdiplusStartupInput gpinput;
     Gdiplus::Image* lpimage;
     CLSID sencoderclsid;

     if((trim(loadflname) == "") || (trim(saveflname) == ""))
       return FALSE;

     // Initialize GDI+.
     gpinput.GdiplusVersion=1;
     Gdiplus::GdiplusStartup(&hgdiplus,&gpinput,NULL);

     if(left(smimetype,4) == "jpg/")
       smimetype="jpeg"+right(smimetype,(long)(smimetype.length()-3));

     if(right(smimetype,4) == "/jpg")
       smimetype=left(smimetype,(long)(smimetype.length()-3))+"jpeg";

     wtxt=strtowstr(smimetype);

     if(getencoderclsid(wtxt.c_str(),&sencoderclsid) == (-1))
     {  
       msgbox("Error "+str(GetLastError()));   
       return FALSE;
     }

     wtxt=strtowstr(loadflname);
     lpimage=Gdiplus::Image::FromFile(wtxt.c_str());

     wtxt=strtowstr(saveflname);

    //Got Here !!

     if(img->Save(wtxt.c_str(),&sencoderclsid,NULL) == Gdiplus::Status::Ok)
       retval=TRUE;
     else
       retval=FALSE;

     //never gets here !!

     delete lpimage;
     lpimage=0;
     Gdiplus::GdiplusShutdown(hgdiplus);

     return retval;
}

escape sequence

$
0
0

hi

please can someone explain why in c++,  \12 escape sequence is equivalent to newline. 12 an octal number

cheers

overloads have similar conversions

$
0
0

Hi,

I am getting the below issue when compiling the code with VS2015. The same is working fine with VC 6.0.

class TimeClass

{

private:

    int h,m,s;

public:

       TimeClass& operator +(const TimeClass&);
      friend TimeClass operator +(const TimeClass&, int);

}

what is wrong with the above code I am getting the bellow error

Error

C2666

'TimeClass::operator +': 2 overloads have   similar conversions

thanks,

CancelIPChangeNotify signal other instance

$
0
0

Write a simple program to   using NotifyAddrChange/CancelIPChangeNotify. When I launch the multiple instances, I noticed the CancelIPChangeNotify signal other instance instead of current instance. Anyone know anything for this?  Another question, what happen if I don't call the CancelIPChangeNotify?

Thanks

Headers include order in project property sheets

$
0
0

Hello there!

I'm working on git repository that contains multiple solutions (with each solution having about 7 or more projects) all these projects (their outputs) depend directly or indirectly on each other, there are plenty of property pages with header include specifications that all projects inherit (having control over header search order is what bothers me here)

My 2 questions are as follows:

if project property page contains multiple include directories specified in : "C/C++ > Additional include directories"

in which order does compiler search these directories? from bottom to top OR from top to bottom (in property sheet)?

if project inherits multiple properties with each property page containing a list of include search directories, in which order does compiler search these include directories? from bottom property page to top (up to project) OR from top to bottom property page?

NOTE: My question is not about includes search order of include directories specified by INCLUDE environment variable nor it is about #include directive specification, the question is about header search order of/I compiler option specified in property sheets that contain multiple search directories specified, assuming also there are multiple property pages inheriting each other where each of these property pages have multiple include directories specified in "C/C++ > Additional include directories"

Thank you!


Querying for keyboard input while processing mouse input

$
0
0

Hi everyone,

I have created a window class and a window with this class. I used normal system Arrow as the cursor type when my mouse hovers on my client area. I am trying to get the code which changes my cursor to a hand when I press CONTROL key. This I have done by processing VK_CONTROL in WM_KEYDOWN message. But when I move my cursor its displaying normal Arrow again. MSDN documentation states that I need to deal with WM_SETCURSOR message(which my app receives whenever I move my mouse) to get that effect. But when I process WM_SETCURSOR, I also need to see if CONTROL key pressed, which means I need to check if WM_KEYDOWN message is pressed in message queue. Is this the most elegant way or is there any way I can query the keyboard myself instead of checking that in message queue. Basically I need to check if both CONTROL key is down AND mouse is moving. 

Thanks in advance..

C++/CLI error in word count

$
0
0

I need get number of words in the sentence. Tried many code examples, but none of them seem to work to me.

cli::array<String^>^ sentences = text->Split('.');
for (int sentenceIndex = 1; sentenceIndex < sentences->Length; ++sentenceIndex) {
String^ sentence = sentences[sentenceIndex];
introwIndex = datagridview->Rows->Add();
Regex->Matches(sentence, " [A - Za - z0 - 9] + ")->Count;// I get error here
datagridview->Rows[rowIndex]->Cells[2]->Value = sentence;
}


How to terminate unmanaged threads called by managed thread?

$
0
0

I have a C++/CLI project, and use a managed DLL which wraps native C++ library like this.

the source code of wrapped dll is as following:

public ref class Protocol
{
private:
	bool sleepSwitch;

public:

	property bool SleepSwitch	{
		void set(bool value) {
			sleepSwitch = value;
		}
	}

	Protocol() {
		sleepSwitch = false;
		tcpptr = new TCPConnection;
	}

	~Protocol() {
		if (nullptr != tcpptr) {
			delete tcpptr;
			tcpptr= nullptr;
		}
	}

	!Protocol() {
		if (nullptr != tcpptr) {
			delete tcpptr;
			tcpptr= nullptr;
		}
	}

	void TCP() {
		if (nullptr == tcpptr) return;
		try {
			tcpptr->TCP(); // execute the unmanaged code
			while (!sleepSwitch) {
				::SleepEx(INFINITE, TRUE);
			}
		}
		catch (ThreadInterruptedException^ /*e*/) {	}
	}
private:
	TCPConnection *tcpptr;
};

Now I interrupt the thread which is created to execute the function in wrapped dll.

Following is the code creating a thread to call the function in C++/CLI, and want to interrupt all the threads generated by calling wrapped function.

Protocol ^protocol = gcnew Protocol();
Thread ^protocol_thread = gcnew Thread(gcnew ThreadStart(protocol, &Protocol::TCP));
protocol_thread->Start();

// do something

protocol_thread->Interrupt();
protocol->SleepSwitch = true;
protocol_thread->Join();

It can terminate the managed thread which execute the function calling unmanaged code successfully.

But it can't terminate the unmanaged threads which generated by calling "tcpptr->TCP();" above. Namely, it leaks memory.

If user want to terminate the connection in UI, how can I achieve?

In the new Windows 10 update, a new system DLL is causing my app to fail to launch

$
0
0
I work on a desktop app that's been around for several years.

In between Windows 10 build 10240 and build 10586, a new DLL was added in system32 and syswow64: fwbase.dll.

My app happens to use a DLL with the same name, installed in the same directory as my exe file. In some way, that new system DLL is stopping our app from launching. I get: "The application was unable to start correctly (0xc0000142)".

If I don't link to our own fwbase.dll, the app launches fine. (But only if I delete the local fwbase.dll. If I don't link to it, and fwbase.dll is still there, I get the error. I find this very odd.)

If I write a very small console application and link to the local fwbase.dll, the DLL works. So the DLL itself is not causing the error.

I'm going to re-write the code to use GetProcAddress(), but this is very unhandy for versions that are already out in the field.

AFAIK, the system should be finding my own fwbase.dll, in the executable's directory. The system's new fwbase.dll shouldn't conflict. I checked HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\KnownDLLs, and the DLL isn't listed there.

Any ideas on what is happening here?


Using RELATIVE_PATH in custom wizards

$
0
0

Dear All,

I am working on a legacy custom wizard that is used for creating specialised VC++ (2015) projects. (The wizard was originally created for a previous version of Visual Studio). The legacy wizard was created in such a way that the wizard files had to be located in fixed particular location. The cause for this is easy to locate, in the ".vsz" file there is a line:

Param="ABSOLUTE_PATH = C:\Emulation Framework\Emulation Core\Main\Source\EmulationAppWizard\Emulation AppWizard V4d"

(Note that rightly or wrongly our .ico, .vsdir and .vsz files are located at C:\Users\<user account folder>\Documents\Visual Studio 2015\Wizards". I am happy to take advice as to whether or not this is the best location for the files).

Because of this line the wizard files need to be located at "C:\Emulation Framework\Emulation Core\..." which is not suitable for every user who will use this wizard.

My initial thought was to change the line to a "RELATIVE_PATH", and drop the various wizard files (in the "1033", "HTML" folders etc) into the same location as the .ico, .vsdir and .vsz files. However, try as I might, I just cannot get the wizard to work with a RELATIVE_PATH. I have asked around, and no one who I have asked has ever been able to get the RELATIVE_PATH to work. I have also searched on line and gone round and round in circles (most of the articles speak about registry entries that just do not exist on my machine).

If anyone can tell me how to use "RELATIVE_PATH" and what it is relative to I would be very grateful.

Thanks,

Andrew.

Windows Media Player Control, hang up during playback

$
0
0
i am developing an application for playing wmv with windows media player control.

Windows Media Player Controls are below.
・IWMPPlayer4
・IWMPControls
・IWMPSettings
・IWMPMedia

but, it will hung up during video playback on rare occasion.
i can confirmed on windows7 32bit pc this problem. 

I've got a dump file below.
FAULTING_IP:
KERNELBASE!RaiseException+58
756a812f c9              leave

EXCEPTION_RECORD:  ffffffff -- (.exr 0xffffffffffffffff)
ExceptionAddress: 756a812f (KERNELBASE!RaiseException+0x00000058)
   ExceptionCode: c0000002
  ExceptionFlags: 00000001
NumberParameters: 0

CONTEXT:  00000000 -- (.cxr 0x0;r)
eax=00000000 ebx=0a00f630 ecx=00000400 edx=00000000 esi=00000002 edi=00000000
eip=776f71b4 esp=0a00f5e0 ebp=0a00f67c iopl=0         nv up ei pl zr na pe nc
cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00000246
ntdll!KiFastSystemCallRet:
776f71b4 c3              ret

PROCESS_NAME:  wplayer.exe
ERROR_CODE: (NTSTATUS) 0xc0000002 - {
EXCEPTION_CODE: (NTSTATUS) 0xc0000002 - {
NTGLOBALFLAG:  0
APPLICATION_VERIFIER_FLAGS:  0
APP:  wplayer.exe
ANALYSIS_VERSION: 6.3.9600.17336 (debuggers(dbg).150226-1500) x86fre
FAULTING_THREAD:  00001520
DEFAULT_BUCKET_ID:  STATUS_NOT_IMPLEMENTED
PRIMARY_PROBLEM_CLASS:  STATUS_NOT_IMPLEMENTED
BUGCHECK_STR:  APPLICATION_FAULT_STATUS_NOT_IMPLEMENTED
LAST_CONTROL_TRANSFER:  from 77416ec2 to 756a812f

STACK_TEXT:
0a00fc74 77416ec2 c0000002 00000001 00000000 KERNELBASE!RaiseException+0x58
0a00fc88 66af4b91 007fd280 66c48d4c 0a00fcc4 msvcrt!_purecall+0x11
0a00fc9c 66af7700 007c6ef8 0a00fcc4 00000000 wmp!CWMPGraphManager::GetCurrentMedia+0x4d
0a00fcd0 66af76b4 0a00fd24 00000000 007c6f90 wmp!CWMPControl::AdjustCurrentPositionForStartTime+0x3e
0a00fcec 66c07179 007c6f90 0a00fd24 00000000 wmp!CWMPControl::get_currentPosition+0x7a
0a00fd04 00c2a827 007cac44 0a00fd24 328a979c wmp!CIWMPNetworkSecurityWrapper::get_bufferingCount+0x36
WARNING: Stack unwind information not available. Following frames may be wrong.
0a00fd44 00c2b299 328a97a8 00000000 007a2c38 wplayer+0xa827
0a00fd70 00c31b35 00000000 328a9770 00000000 wplayer+0xb299
0a00fda8 00c31bbf 00000000 0a00fdc0 7617ee6c wplayer+0x11b35
0a00fdb4 7617ee6c 007a2c38 0a00fe00 77713ab3 wplayer+0x11bbf
0a00fdc0 77713ab3 007a2c38 7dc8b86e 00000000 kernel32!BaseThreadInitThunk+0xe
0a00fe00 77713a86 00c31b5b 007a2c38 00000000 ntdll!__RtlUserThreadStart+0x70
0a00fe18 00000000 00c31b5b 007a2c38 00000000 ntdll!_RtlUserThreadStart+0x1b

FOLLOWUP_IP:
wmp!CWMPGraphManager::GetCurrentMedia+4d
66af4b91 5d              pop     ebp

SYMBOL_STACK_INDEX:  2
SYMBOL_NAME:  wmp!CWMPGraphManager::GetCurrentMedia+4d
FOLLOWUP_NAME:  MachineOwner
MODULE_NAME: wmp
IMAGE_NAME:  wmp.dll
DEBUG_FLR_IMAGE_TIMESTAMP:  55411dac
STACK_COMMAND:  ~14s; .ecxr ; kb
FAILURE_BUCKET_ID:  STATUS_NOT_IMPLEMENTED_c0000002_wmp.dll!CWMPGraphManager::GetCurrentMedia
BUCKET_ID:  APPLICATION_FAULT_STATUS_NOT_IMPLEMENTED_wmp!CWMPGraphManager::GetCurrentMedia+4d
ANALYSIS_SOURCE:  UM
FAILURE_ID_HASH_STRING:  um:status_not_implemented_c0000002_wmp.dll!cwmpgraphmanager::getcurrentmedia
FAILURE_ID_HASH:  {2ac96fdf-730a-e2ab-fcee-863ab99151b2}
Followup: MachineOwner

please tell me, what is the possible reason of error? 
and, does anyone have any solutions?

developed by
Windows7 64bit
Visual Studio 2010 C++

thanks

Using GetWindowLongPtr function to retrieve handle to an application

$
0
0

Hi everyone,

I used the following line to get the handle for my application window from windProc

HINSTANCE appHandle=GetWindowLongPtr(hWnd,GWLP_HINSTANCE);

which promptly returned an error saying that "a value of type long cannot be used to initialize an entity of type HINSTANCE". But when I used HINSTANCE word as a return type, it ended up being fine.

HINSTANCE appHandle=(HINSTANCE)GetWindowLongPtr(hWnd,GWLP_HINSTANCE);

I know the return value is being modified when I do that. But I am interested as to why I have to do this. Isn't HINSTANCE a type of long_ptr? Actually the same thing happened earlier when I tried to assign GetStockBrush function to app.hbrBackground. It forced me to specify the return type as HBRUSH.

free() method throw exception when release memory block in the heap

$
0
0

Each time, a data block is read from a file and allocate a block of memory by pDataLine =  (char *)malloc (strlen (pDeblockLine) + 1)).

When I free this memory block through free(pDataLine),throw Exception code: 0xc0000005.

Note: This program is an Win32 program, so there is multiple threads in the process. After malloc(),  there are many malloc() and free() in those threads before free(pDataLine) is called. 

Windows heap manager will allocate this block, each block has a 32 bytes header (_CrtMemBlockHeader).   I traced the allocated memory block and the header, including the debug protected 4 Bytes before the head and after the tail of the pDataLine,  there is no memory crash or memory overflow before this block is freed.   But when this block is freed and the heap manager try to recollect this block,  the error occurs.

This error occurs in _RtlpLowFragHeap() method.  I can’t debug this method through c/c++ instruction, I can only view the disassembly instruction.  I attach the disassembly instructions here:

@RtlpLowFragHeapFree@8:
7784E39A  mov         edi,edi  
7784E39C  push        ebp  
7784E39D  mov         ebp,esp  
7784E39F  sub         esp,28h  
7784E3A2  push        ebx  
7784E3A3  push        esi  
7784E3A4  push        edi  
7784E3A5  lea         edi,[edx-8]  
7784E3A8  cmp         byte ptr [edi+7],5  
7784E3AC  je          @RtlpLowFragHeapFree@8+64E63h (778B31FDh)  
7784E3B2  mov         eax,dword ptr [edi]  
7784E3B4  mov         esi,edi  
7784E3B6  shr         esi,3  
7784E3B9  xor         esi,eax  
7784E3BB  xor         esi,dword ptr ds:[779200A4h]  
7784E3C1  mov         dword ptr [ebp-4],edi  
7784E3C4  xor         esi,ecx  
7784E3C6  mov         eax,dword ptr [esi+4]  
7784E3C9  mov         dword ptr [ebp-0Ch],eax  
7784E3CC  mov         byte ptr [edi+7],80h  
7784E3D0  mov         byte ptr [edi+6],0  
7784E3D4  mov         ebx,dword ptr [esi+8]  
7784E3D7  mov         ecx,dword ptr [esi+0Ch]  
7784E3DA  mov         dword ptr [ebp-20h],ebx  
7784E3DD  add         ebx,1  
7784E3E0  mov         dword ptr [ebp-1Ch],ecx  
7784E3E3  adc         ecx,1  
7784E3E6  and         ebx,7FFFh  
7784E3EC  cmp         bx,word ptr [esi+14h]  
7784E3F0  je          @RtlpLowFragHeapFree@8+55FFh (77853999h)  
7784E3F6  mov         eax,dword ptr [ebp-20h]  
7784E3F9  mov         edx,dword ptr [ebp-1Ch]  
7784E3FC  shrd        eax,edx,10h  
7784E400  mov         word ptr [edi+8],ax  
7784E404  sub         edi,dword ptr [ebp-0Ch]  
7784E407  xor         eax,eax  
7784E409  shr         edi,3  
7784E40C  shld        eax,edi,10h  
7784E410  shl         edi,10h  
7784E413  shr         edx,10h  
7784E416  or          ebx,edi  
7784E418  or          ecx,eax  
7784E41A  mov         eax,dword ptr [esi]  
7784E41C  mov         dword ptr [ebp-8],1  
7784E423  mov         dword ptr [eax],esi  
7784E425  mov         eax,dword ptr [ebp-20h]  
7784E428  mov         edx,dword ptr [ebp-1Ch]  
7784E42B  lea         edi,[esi+8]  
7784E42E  lock cmpxchg8b qword ptr [edi] 

 The program will crash at line 44(  7784E423  mov         dword ptr [eax],esi ),  because [eax] point to 0x00000000 address.
There is no jump when enter RtlpLowFragHeadFree method, the instruction will execute in sequence.

Why this happen?

Thanks.


 


How to save WMF image file.

$
0
0

Hi,

I am new to this topic.

i am using this method  --->  m_image.Save(lpszPathName);

it saves .bmp, .jpeg, .png, .gif, .tif  formats but not saves the WMF/EMF Format.

what i do for saving the image as .wmf format.

please help me.

Thanks in advance.



sree2sri


Purpose of RDW_NOERASE flag of RedrawWindow()

$
0
0

I am not sure what is the purpose of the RDW_NOERASE flag of the RedrawWindow() function, this is what MSDN says:

"RDW_NOERASE Suppresses any pending WM_ERASEBKGND messages."

Based on this MSDN statement, I think that this is what this flag does: If there is a pending WM_ERASEBKGND message that is supposed to be sent, then if I specify the RDW_NOERASE flag, the WM_ERASEBKGND message will not be sent anymore.

So I wrote the following code to test this (hWnd is the parent window):

case WM_LBUTTONDOWN:  // left mouse button clicked
{
    /* Send a WM_PAINT and WM_ERASEBKGND messages (they will be sent to the window procedure when the code execution is back to the message loop) */
    InvalidateRect(hWnd, NULL, TRUE);

    /* Now I assume that this call will prevent the WM_ERASEBKGND message from being sent (and hence only a WM_PAINT message will be sent) */
    RedrawWindow(hWnd, NULL, NULL, RDW_NOERASE);
}
break;

But it did not work as expected, and the WM_ERASEBKGND message was still being sent.

So did I wrongly understood the purpose of this flag? and if so, then what is its true purpose?

C++/CLI information printed into one column of csv file

$
0
0

I have datagridview with information that I want to export to a file, but all information is being printed in the first column.

int cols;
//open file
StreamWriter ^wr = gcnew StreamWriter("output1.csv", false,  Encoding::UTF8);
//determine the number of columns and write columns to file
cols = datagridview->Columns->Count;
for (int i = 0; i < cols; i++){
wr->Write(analize->Columns[i]->Name->ToString()->ToUpper());
}
wr->WriteLine();
//write rows to excel file
for (int i = 0; i < (datagridview->Rows->Count); i++){
for (int j = 0; j < cols; j++){
if (datagridview->Rows[i]->Cells[j]->Value ){
wr->Write(datagridview->Rows[i]->Cells[j]->Value);				}
}
wr->WriteLine();
}
wr->Close();

Visual Studio 2010 and 2015 Coexistance

$
0
0

We are moving from Visual Studio 2010 to Visual Studio 2015. However, we need to continue to support the legacy software which was built in VS 2010. So we need the two IDEs to coexist on developer machines.

Most of our projects require a certain set of libraries: DirectX, SDK, Boost, etc. The include and library directories for these have been defined in Microsoft.Cpp.Win32.user property sheet. We wanted to define it once and not have to do this for each project. The problem is that this property sheet is SHARED between VS 2010 and VS 2015. The version and paths of the libraries are different for VS 2010 and VS 2015.

A possible solution we came up with was to define the include and library directories in Microsoft.Cpp.Default.Props property sheet. In fact, there are two versions of this file: one for VS 2010 and another for VS 2015. Microsoft.Cpp.Win32.user inherits from the appropriate property sheet in each build environment. We figured we could simply move the definitions from the Win32.user property sheet to the Default property sheet (for Vs 2010) and define corresponding directories for VS 2015 in its own version of Default property sheet.

However, we noticed that although Win32.user does appear to inherit from Default, the project is unable to find the header files. The "Inherit from parent or project defaults" checkbox is selected in Win32.user property sheet and the project itself. Although the paths *appear* to be inherited, the header files are not found during compilation and compilation fails.

How do we make this work? Thanks in advance.

Prashanta

11-26-15 AMD-ATIVideo/display dll fail

$
0
0

New failure at boot.

Win 10  At boot, both monitors come up, until Win starts

Sets to default/lowest resolution, does not detect monitor 2

Radeon HD 4XXX

AMD Phenom II 810<sub></sub><sup></sup><strike></strike>

Tried AMD Catalyst 13.1 driver package

Dll can be coaxed to install, no improvement.

********

Reinstalled  10. Nice, very speedy, back up all good

except vid dll fail. Same issues

One monitor at default rez, does not see monitor 2.

Thanks!

Jim

Processing mouse inputs

$
0
0

I need my application to reset my cursor position to the center of the client area whenever I move my mouse. To do this I have inserted the following code under WM_MOUSEMOVE

case WM_MOUSEMOVE:
		{
			GetClientRect(hWnd,client_rect);
			(*pt).x=client_rect->right;(*pt).y=client_rect->bottom;
			ClientToScreen(hWnd,pt);
			SetCursorPos((*pt).x/2,(*pt).y/2);
		}
		break;

Every time I move my mouse in the client area, my application is freezing. If I remove this piece of code, everything is fine. So something is wrong here. Documentation states that the calling process must have WINSTA_WRITEATTRIBUTES access to the window station. Is this the problem?

I have not captured the mouse from my application because I fear this would prevent others applications from getting mouse related inputs.

Thanks in advance

Viewing all 15302 articles
Browse latest View live


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