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

Detect the port to which a GPS device is connected

$
0
0

Hello Everyone,

I am working on Geo-Tracking based on GPS.

Is there a way to find out the port on which GPS device connected?

I tried the way to do this is to open each port, and listen a bit for NMEA data, Is there is any other way?

Thanks in advance,

Nilesh


VS2010: compiled the program, but windows is unable to start the program.

$
0
0

I just recently downloaded VS2010 and I tried building a simple program to test it to make sure that it works. It says that the program compiled successfully, but windows gave me a new window that says:

Unable to start program.

The specified file is an unrecognized or unsupported binary format.

What do I need to do to fix this problem? I still have the VS2010 program on a disk in case I need to redownload it or I can download VS2012 if needed.

Can't access VSS under Windows 8.1

$
0
0

Hello,

i am trying to develop a simple backup solution by using the VSS service.

Right now i found this code:

#include <vss.h>
#include <vswriter.h>
#include <vsbackup.h>

typedef HRESULT(STDAPICALLTYPE *_CreateVssBackupComponentsInternal)(__out IVssBackupComponents **ppBackup);
typedef void (APIENTRY *_VssFreeSnapshotPropertiesInternal)( __in VSS_SNAPSHOT_PROP *pProp);

static _CreateVssBackupComponentsInternal CreateVssBackupComponentsInternal_I;
static _VssFreeSnapshotPropertiesInternal VssFreeSnapshotPropertiesInternal_I;

int _tmain(int argc, _TCHAR* argv[])
{
	HRESULT result;
	HMODULE vssapiBase;
	IVssBackupComponents *backupComponents;

	vssapiBase = LoadLibrary(L"vssapi.dll");

	if (vssapiBase)
	{
		CreateVssBackupComponentsInternal_I = (_CreateVssBackupComponentsInternal)GetProcAddress(vssapiBase, "CreateVssBackupComponentsInternal");
		VssFreeSnapshotPropertiesInternal_I = (_VssFreeSnapshotPropertiesInternal)GetProcAddress(vssapiBase, "VssFreeSnapshotPropertiesInternal");
	}

	if (!CreateVssBackupComponentsInternal_I || !VssFreeSnapshotPropertiesInternal_I)
		abort(); // Handle error

	result = CreateVssBackupComponentsInternal_I(&backupComponents);

	if (!SUCCEEDED(result))
		abort(); // Handle error

When running the application i get abort() called on the last line.

I tried to run the application as Admininistrator, by setting it in the manifest. But i had no luck.

It seems a permission problem.

Any suggestion? Thank you!

0xc000007b on Visual C++ 2013 Relase Binary

$
0
0

Hello.

I'm having a hard time figuring out how to build a Windows 7 valid exe with Visual Studio 2013. The solution consists on the following items:

c++/cli application containing some forms.

c# class library with a forms control.

a couple of native c++ static libraries.

The application runs fine in my development machine with windows 8.1, however it crashes to 0xc000007b on windows 7 x64. This is a w7 x64 clean install with vc10,vc11 and vc12 redists (x86 and x64 versions) installed. My solution has all c++ projects set to v120_xp (v120 doesn't work either). And the same .net targets both in the c# and in the c++/cli projects (currently 4.0). It builds fine with 0 warnings.

A quick dependency walker check shows some random API-MS-WIN-STUFF with I understand is a DW limitation and DCOMP.DLL, GPSVC.DLL and IESHIM.DLL. I wonder why DCOMP.DLL shows up there, and how should I get rid of this. I ran out of ideas here.

Regards.


Isaac Lascasas




Initializing System::String with a managed array of char

$
0
0

I'm trying out my first project with visual C++, and I'm having a hard time figuring out a way to initialize a String from an array of char. I am taking an unsigned 32 bit integer as an IP address and generating the text equivalent of it. I felt it was easier to define an array of the maximum size, and parse the address into the array one element at a time then initialize a String based on the final null terminated character array than try to concat an existing String with the characters as I parse.

I am getting 

IP_validate.cpp(170): error C2664: 'System::String::String(const wchar_t *)' : cannot convert parameter 1 from 'cli::array<Type> ^' to 'const wchar_t *'
1>          with
1>          [
1>              Type=char
1>          ]

as an error, and I'm having a very hard time implementing a solution. One promising way I found online was using Encoding::Convert, but I have yet to figure out how to actually make that work. Copy & pasting my code looks like a mess in the forum, so here is the important bits (The parsing of the numbers works fine, please assume that the array temp_ip_slate correctly contains the values for the IP address and is null terminated). 

array<char>^ temp_ip_slate = gcnew array<char>(16); 
//An easier way to construct the ascii IP address (through array[element])

String^ temp_ip_string = gcnew String(temp_ip_slate); 
//The string used to construct the IP address, initialized with our finished IP address
return(temp_ip_string); //Return the finished String back
You can see what I would LIKE to do, but there is no method to construct a String like that. What would be the easiest way to accomplish this?


How to get the message owner of CMenu window?

$
0
0

    For CMenu of MFC, normally we will use member function "BOOL TrackPopupMenu( UINT nFlags, int x, int y, CWnd* pWnd, LPCRECT lpRect = NULL )" to pop up menu, here the parameter "CWnd* pWnd" identifies the window that owns the pop-up menu. So how could I get the owner window "pWnd" when I only have a got a pointer of CMenu?

    Following are codes that get the menu, and how to get the owner window of menu?

           CWnd *pMenuWindow = CWnd::FromHandle(::GetTopWindow());// Get the menu window

           HMENU hMenu = (HMENU)(pMenuWindow->SendMessage(MN_GETHMENU, 0, 0));

           CMenu *pPopupMenu = CMenu::FromHandle(hMenu);// Get the menu

           ......... // Here how to get the owner of pPopupMenu? (means parameter pWnd which is used when call TrackPopupMenu)

           //  if call pMenuWindow->GetParent(), it is NULL, so this way is impossible to get the message owner of CMenu window


How to add tooltip for column header of CListCtrl ?

$
0
0

     As you see in following picture, the column header of case 1 show the whole text, but for case 2, the column header only show part of the text because we made the width small, so how to add tooltip for the column header in this case? Just similiar to ListCtrol items, when we move mouse on any item, if the text is not fully shown, it will show a tooltip. But Now we want the similar behavior for the head column. 



Need confirmation about the note below in the Standard.

$
0
0

Paragraph §3.10/2 in the Standard:

Whenever a glvalue appears in a context where a prvalue is expected, the glvalue is converted to a prvalue; see 4.1, 4.2, and 4.3. [ Note: An attempt to bind an rvalue reference to an lvalue is not such a context; see 8.5.3. —end note ]

I believe the note above expresses the fact that one has to use std::move() to convert an lvalue into an rvalue reference., i.e., you can't rely on the compiler to do that automatically for you. Is that correct?



autoexp.dat Visualizers in VS11 Developer Preview broken?

$
0
0

It seems that if I add visualizer definitions to the autoexp.dat file in the Visual Studio 11 preview, they do not work. Is this a known issue, or is there some other way to define custom visualizers for 11?

It appears that the file is identical to the VS 2010 version, so I would expect the visualizers I wrote for 2010 to work in 2011 as well.  The autoexp.dat file I am editing is found at "C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\Packages\Debugger"

Thanks!

Registration of Visual C++ 2005 -- link within the app does not work

$
0
0

The link "Register Now" from C++ 2005  is to 

go.microsoft.com/fwlink/?linkid=51341&lcid=1033&h=4c795cc9e64a90f5&c=&pid=76542-000-0000011-00125&bn=050727.867

but it gives a 404 error.  How can I register?  I had registered a year or two back on another computer.

In hope

Michael.


Microsoft Visual C++ Runtime Library Error

$
0
0
 I am tryging to download pictures from my camera card through my printer which is an HP Photosmart 6520 and everytime that I I try and transfer the pictures to my computer, I get the error message Program C:\Program Files\HP\Digital Imaging\Unload\hpqPhUnl.exe. I've never had problems before today, could it be because I am using an older camera card that I didnt use in a while? It's telling me that this application has requested Runtime to terminate in an unusual way and that I should contact the applications support team for more information. Is there anything I can do on my end to resolve this issue?

GetGPOList API returns error 0x534 (ERROR_NONE_MAPPED)

$
0
0

GetGPOList API returns error 0x534 (1332, ERROR_NONE_MAPPED)

I tried this code :

HANDLE hToken = NULL;
	bool success = true;
	if (OpenProcessToken (GetCurrentProcess(), TOKEN_IMPERSONATE | TOKEN_READ | TOKEN_MANDATORY_POLICY_NEW_PROCESS_MIN, &hToken)) {
		PGROUP_POLICY_OBJECT gpo = NULL;
		if (GetGPOList (hToken, NULL, NULL, NULL, GPO_LIST_FLAG_MACHINE, &gpo)) {
			FreeGPOList (gpo);
		} else {
			ShowLastError (3);
			success = false;
		}
		CloseHandle (hToken);
	} else {
		ShowLastError (3);
		success = false;
	}

This looks fine, and I even tried TOKEN_ACCESS_ALL, same result.

Is it something wrong with that Token?
I didn't specify a Account name, and I just used this process' token, and http://social.msdn.microsoft.com/Forums/en-US/vcgeneral/thread/ccf1f498-3237-45ac-9985-438eb576ee07 did not help me to solve this.
ShowLastError is a function that reports an error by GetLastError().

Anybody knows why this happens and how to fix it?

- I just knew that this problem is because of GetUserNameEx. It says that the user name is not available in the fully qualified distinguished name. What happend? My account does not have fully qualified DN?


Jin-oh on



Cannot find interface "IMsRdpDrive" when using VS2008 (MFC class form typelib) to add an interface of mstscax.dll

$
0
0

Recently, I'm going to do a remote desktop software with C++.And I found its introduction in msdn,here is the address.

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

So I use the mstscax.dll to complete this.But what is the problem is that by the way of adding MFC class form typelib I cannot find the interface IMsRdpDrive on list.

In another way of adding MFC class form ActiveX control,I found the interface I want. But,when I'm gonna add it to my project,there is an error "cannot find coclass for interface IMsRdpDrive".

What I want ask are the following 2 questions.

1.What is the difference of two way(MFC class from typelib and MFC class form activeX control)?

2.Why cannot find coclass for interface IMsRdpDrive?



how to give privilege to C drive for windows8 using VC++ in VS2008

$
0
0

Dear Friends,

Application demanding Admin rights, when I install application in client PC. All supporting files pasted under "C:" driver. Due to insufficient privilege (read and Write) the application couldnt to create file or read a file from "C:" driver (supporting file in "C:\"). I have tired out some of the program to grant privilege. But no use in it.

void AllowEveryone() { PACL pDacl,pNewDACL; EXPLICIT_ACCESS ExplicitAccess; PSECURITY_DESCRIPTOR ppSecurityDescriptor; PSID psid; LPTSTR lpStr; // char str[5] = path; //lpStr = str.GetBuffer(); lpStr = _T("C:"); GetNamedSecurityInfo(lpStr, SE_FILE_OBJECT,DACL_SECURITY_INFORMATION, NULL, NULL, &pDacl, NULL, &ppSecurityDescriptor); ConvertStringSidToSid(_T("S-1-1-0"), &psid); ExplicitAccess.grfAccessMode = SET_ACCESS; ExplicitAccess.grfAccessPermissions = GENERIC_ALL; ExplicitAccess.grfInheritance = CONTAINER_INHERIT_ACE | OBJECT_INHERIT_ACE; ExplicitAccess.Trustee.MultipleTrusteeOperation = NO_MULTIPLE_TRUSTEE; ExplicitAccess.Trustee.pMultipleTrustee = NULL; ExplicitAccess.Trustee.ptstrName = (LPTSTR) psid; ExplicitAccess.Trustee.TrusteeForm = TRUSTEE_IS_SID; ExplicitAccess.Trustee.TrusteeType = TRUSTEE_IS_UNKNOWN; SetEntriesInAcl(1, &ExplicitAccess, pDacl, &pNewDACL); SetNamedSecurityInfo(lpStr,SE_FILE_OBJECT,DACL_SECURITY_INFORMATION,NULL,NULL,pNewDACL,NULL); LocalFree(pNewDACL); LocalFree(psid); } int _tmain(int argc, _TCHAR* argv[]) { AllowEveryone(); return 0; }

Folks, your suggestion higly appreciated and it means a lot to me.

Thanks and Regards,

S Shanmuga Raja

COleDataSource clipboard method is crashing in Widows XP after closing the application

$
0
0

Our project(MFC Active X project) is developed using VC++ 2010.
We are using COleDataSource methods to copy data to clipboard. We are using the below code snippet to copy data on clipboard

COleDataSource* pSource = new COleDataSource();
HGLOBAL hText = ::GlobalAlloc(GMEM_SHARE, iTextSize);
LPSTR pText = (LPSTR) :: GlobalLock(hText);
ASSERT(pText);
strcpy(pText, strClipboardText);
::GlobalUnlock(hText);
pSource->CacheGlobalData(CF_TEXT, hText);
pSource->Flushclipboard();
The above code snippet is in ActiveX control. When we close the application it is crashing in XP. The same code snippet is working in Window 7.

The call stack is showing as below

    mfc100.dll!AFX_MAINTAIN_STATE2::AFX_MAINTAIN_STATE2() + 0x34 bytes    
    mfc100.dll!COleDataSource::XDataObject::GetData() + 0x1a bytes    
    ole32.dll!HandleFromHandle() + 0x23 bytes    
    ole32.dll!RenderFormat() + 0x11b bytes    
    ole32.dll!_ClipboardWndProc@16() + 0x29403 bytes    
    user32.dll!_InternalCallWinProc@20() + 0x28 bytes    
    user32.dll!_UserCallWinProcCheckWow@32() + 0xb7 bytes    
    user32.dll!_DispatchClientMessage@20() + 0x4d bytes    
    user32.dll!___fnDWORD@4() + 0x24 bytes    
    ntdll.dll!_RtlIpv6AddressToStringExW@20() + 0xa5 bytes    
    ole32.dll!_OleFlushClipboard@0() + 0x87 bytes    
    mfc100.dll!AfxOleTerm() + 0xa bytes    
    mfc100.dll!AfxOleTermOrFreeLib() + 0x13 bytes    
    mfc100.dll!AfxPostQuitMessage() + 0x1e bytes    
    mfc100.dll!CWnd::OnNcDestroy() + 0x4d bytes    
    mfc100.dll!CWnd::OnWndMsg() + 0x47e bytes    
    mfc100.dll!CWnd::WindowProc() + 0x24 bytes    
    mfc100.dll!AfxCallWndProc() + 0xb5 bytes    
     ...

NOTE: The same scenario is working when application build in debug mode(mfc100d.dll)


how to enum a domain with LDAP?

$
0
0
bool CGetInfor::GetActiveUser(TCHAR * lpCommand[MAX_PATH],int ArgCount)
{
 TCHAR tcServerAddr[MAX_PATH]={0};
 TCHAR tcUserName[MAX_PATH]={0};
 TCHAR tcPassWord[MAX_PATH]={0};
 TCHAR tcFilePath[MAX_PATH]={0};
 _tcscpy_s(tcServerAddr,lpCommand[2]);
 if(ArgCount==5)
 {
  _tcscpy_s(tcUserName,lpCommand[3]);
  _tcscpy_s(tcPassWord,lpCommand[4]);
 }
  HRESULT     hr= S_FALSE;
 IADsContainer * lpObject;
 TCHAR Connstr[MAX_PATH]={0};
 _tcscpy_s(Connstr,L"LDAP://cn=users,dc=corp,dc=local,dc=com"); ///
 if(ArgCount==5)
  hr=ADsOpenObject(Connstr,tcUserName,tcPassWord,ADS_SERVER_BIND,IID_IADsContainer,(void**)&lpObject);
 else
 {
  printf("simple bind \r\n");
  hr=ADsGetObject(Connstr,IID_IADsContainer,(void**)&lpObject);
 }
 if (SUCCEEDED(hr))
 {
  BSTR bstrName;
  LPUNKNOWN pUnk = NULL;
  hr = lpObject->get__NewEnum(&pUnk);
  lpObject->Release();
  IEnumVARIANT *pEnum=NULL;
  hr = pUnk->QueryInterface(IID_IEnumVARIANT,(
   void**)&pEnum); 
  if(FAILED(hr)) 
  {
   printf("QueryInterface  failed\r\n");
   goto cleanup;
  }   
  ULONG dwEnumCount=0;
  VARIANT var;
  BSTR bstr = NULL;
  ULONG lFetch=0;
  VariantInit(&var);
  hr = pEnum->Next(1, &var, &lFetch);
  while(SUCCEEDED(hr) && lFetch > 0)
  {
   if(lFetch==1)
   {
    IADsGroup * pObject=NULL;
    IADsMembers * pMember=NULL;
    IDispatch *pDispatch = NULL;
    pDispatch = V_DISPATCH(&var);
    IADs * pADs=NULL;
     hr = pDispatch->QueryInterface(IID_IADsGroup,(void**) &pObject);
    if (SUCCEEDED(hr))
    {    
     dwEnumCount++;
     //Getgroupname   
  hr = pObject->get_Name(&bstrName);
     if(hr==S_OK)
     {
      _bstr_t p=bstrName;
      char *a=p;
      printf("Group %d name: %-30s \r\n ",dwEnumCount,a);
      OutToFileA("Group %d name: %-30s \r\n ",dwEnumCount,a);
      bstrName=NULL;
     }
     //getGroupDescripiton
     hr=pObject->get_Description(&bstrName);
     if(hr==S_OK)
     {
      _bstr_t p=bstrName;
      char *a=p;
      //MultiOutToFile(a);
      OutToFileA("Group Description : %s \r\n",a);
      printf("Group Description :%s \r\n",a);
      bstrName=NULL;
     }
     //getgroupmember
     hr=pObject->Members(&pMember);
     if (FAILED(hr)) 
     {
      printf("\t no member!");
      OutToFileA("\t no member! \r\n");
     }
     else
     {
      if(pMember!=NULL)
      {
       EnumMembers(pMember);
      }
      printf("\r\n");
      OutToFileA("\r\n\r\n\r\n");
     }     
     SysFreeString(bstrName);
     if(pObject!=NULL) pObject->Release();
     pDispatch->Release();
     pDispatch=NULL;
    }
   } 
   VariantClear(&var);
   hr = pEnum->Next(1, &var, &lFetch);
  }
 }
 else
 {
  printf("Connect Domain Server Failed.");
 }
cleanup:
 return TRUE;
}

if i use WINNT ,i can do it,but i use LDAP ,i cant .why not?

how to use graphics in visual studio 2013

$
0
0
how to use graphics to davelope game in c++ visual studio 2013.?

Visual Studio 2013: wmiatlprov.h missing

$
0
0

Hi,

we are currently upgrading our VC++ projects so that they use the v120 toolset (Visual Studio 2013). Before we used the v100 toolset (VS 2010).

One of our project is including the file wmiatlprov.h and using classes like IWbemInstProviderImpl and CInstanceProviderHelper (which are defined in wmiatlprov.h). The problem is that this header file cannot be opened (because it does not exist in the include search paths).

VS2010 installed the file in "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include", but the file exists neither in the corresponding directory for VS2012 nor for VS2013. I also cannot find the file in Windows SDKs include folder (I actually searched the complete hard disk for that file, and the only directory which contains the file is the VS2010 folder stated above).

I also searched for the classes IWbemInstProviderImpl and CInstanceProviderHelper in the VS2013/VS2012 include files, but I cannot find them (maybe the classes have been moved to a different header file).

Both searches were done on a colleague's machine also.

I also cannot find any information about changes regarding wmiatlprov.h, IWbemInstProviderImpl or CInstanceProviderHelper.

Are there any alternatives for these classes? Why was this file removed with VS2012/VS2013?

Thanks for your help!

ActiveX bitmap push button built in VS 2013

$
0
0
I migrated an ActiveX project from VS 2008 to VS 2013 that has various controls including bitmap push button. When I build under C++ VS 2013, the control works in dialogs but is disabled in CDialogBar derived classes. I am not sure why VS 2013 build works incorrectly?

CreateDesktop with custom background or custom wallpaper

$
0
0
I want to set a custom wallpaper for  desktop created with CreateDesktop(). Note the the wallpaper should only set for newly created desktop, the wallpaper of default desktop should not be changed.

Thanks, Renjith V R

Viewing all 15302 articles
Browse latest View live


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