Search Results

Search found 686 results on 28 pages for 'vc'.

Page 11/28 | < Previous Page | 7 8 9 10 11 12 13 14 15 16 17 18  | Next Page >

  • Problem with "moveable-only types" in VC++ 2010

    - by Luc Touraille
    I recently installed Visual Studio 2010 Professional RC to try it out and test the few C++0x features that are implemented in VC++ 2010. I instantiated a std::vector of std::unique_ptr, without any problems. However, when I try to populate it by passing temporaries to push_back, the compiler complains that the copy constructor of unique_ptr is private. I tried inserting an lvalue by moving it, and it works just fine. #include <utility> #include <vector> int main() { typedef std::unique_ptr<int> int_ptr; int_ptr pi(new int(1)); std::vector<int_ptr> vec; vec.push_back(std::move(pi)); // OK vec.push_back(int_ptr(new int(2)); // compiler error } As it turns out, the problem is neither unique_ptr nor vector::push_back but the way VC++ resolves overloads when dealing with rvalues, as demonstrated by the following code: struct MoveOnly { MoveOnly() {} MoveOnly(MoveOnly && other) {} private: MoveOnly(const MoveOnly & other); }; void acceptRValue(MoveOnly && mo) {} int main() { acceptRValue(MoveOnly()); // Compiler error } The compiler complains that the copy constructor is not accessible. If I make it public, the program compiles (even though the copy constructor is not defined). Did I misunderstand something about rvalue references, or is it a (possibly known) bug in VC++ 2010 implementation of this feature?

    Read the article

  • C++ SQLDriverConnect API

    - by harshalkreddy
    Hi, I am using visual studio 2008 and sql server 2008 for developing application(SQL server is in my system). I need to fetch some fields from the database. I am using the SQLDriverConnect API to connect to the database. If I use the "SQL_DRIVER_PROMPT" I will get pop window to select the data source. I don't want this window to appear. As per my understanding this window will appear if we provide insufficient information in the connection string. I think I have provided all the information. I am trying to connect with windows authentication. I tried different options but still no luck. Please help me in solving this problem. Below is the code that I am using: //******************************************************************************** // SQLDriverConnect_ref.cpp // compile with: odbc32.lib user32.lib #include <windows.h> #include <sqlext.h> int main() { SQLHENV henv; SQLHDBC hdbc; SQLHSTMT hstmt; SQLRETURN retcode; SQLWCHAR OutConnStr[255]; SQLSMALLINT OutConnStrLen; SQLCHAR ConnStrIn[255] = "DRIVER={SQL Server};SERVER=(local);DSN=MyDSN;DATABASE=MyDatabase;Trusted_Connection=yes;"; //SQLWCHAR *ConntStr =(SQLWCHAR *) "DRIVER={SQL Server};DSN=MyDSN;"; HWND desktopHandle = GetDesktopWindow(); // desktop's window handle // Allocate environment handle retcode = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &henv); // Set the ODBC version environment attribute if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO) { retcode = SQLSetEnvAttr(henv, SQL_ATTR_ODBC_VERSION, (SQLPOINTER*)SQL_OV_ODBC3, 0); // Allocate connection handle if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO) { retcode = SQLAllocHandle(SQL_HANDLE_DBC, henv, &hdbc); // Set login timeout to 5 seconds if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO) { SQLSetConnectAttr(hdbc, SQL_LOGIN_TIMEOUT, (SQLPOINTER)5, 0); retcode = SQLDriverConnect( // SQL_NULL_HDBC hdbc, desktopHandle, (SQLWCHAR *)ConnStrIn, SQL_NTS, OutConnStr, 255, &OutConnStrLen, SQL_DRIVER_NOPROMPT); // Allocate statement handle if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO) { retcode = SQLAllocHandle(SQL_HANDLE_STMT, hdbc, &hstmt); // Process data if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO) { SQLFreeHandle(SQL_HANDLE_STMT, hstmt); } SQLDisconnect(hdbc); } SQLFreeHandle(SQL_HANDLE_DBC, hdbc); } } SQLFreeHandle(SQL_HANDLE_ENV, henv); } } //******************************************************************************** Thanks in advance, Harsha

    Read the article

  • Weird characters at the beginning of a LPTSTR? C++

    - by extintor
    I am using this code to get the windows version: define BUFSIZE 256 bool config::GetOS(LPTSTR OSv) { OSVERSIONINFOEX osve; BOOL bOsVersionInfoEx; ZeroMemory(&osve, sizeof(OSVERSIONINFOEX)); osve.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); if( !(bOsVersionInfoEx = GetVersionEx ((OSVERSIONINFO *) &osve)) ) return false; TCHAR buf[BUFSIZE]; StringCchPrintf(buf, BUFSIZE, TEXT("%u.%u.%u.%u"), osve.dwPlatformId, osve.dwMajorVersion, osve.dwMinorVersion, osve.dwBuildNumber); StringCchCat(OSv, BUFSIZE, buf); return true; } And I am testing it with: LPTSTR OSv= new TCHAR[BUFSIZE]; config c; c.GetOS(OSv); MessageBox(OSv, 0, 0); And in the msgbox I get something like this äì5.1.20 (where 5.1.20 is = to OSv) but the first 2 or 3 chars are some weird characters that I don't know when they came from. Even stranger, if I call that second piece again it shows it ok, it only show the weird characters the first time I execute it. Does someone has an idea what's going on here?

    Read the article

  • Casting between variant and bstr_t causing inconsisten crash in Windows 2008

    - by user58470
    We have a C# application, calling a simple C++ wrapper class, that then calls an existing C++ DLL. The C++ code is all VC++ 6.0. We are getting inconsistent behaviour, but the crash, when it happens, always happens within the C++ wrapper DLL, and always in the same spot (have confirmed using painful logging statements). It never happens on any environment except on Windows 2008, so we suspect some bad-but-not-fatal memory trashing is going on that somehow Windows 2008 is being more mindful of. Here's the relevant code, if anyone has any ideas on why this might be crashing it would be much appreciated. We've been tearing our hair out for a few days and project timelines are slipping all for the want of being able to return a simple string back to C#... I've been told we've tried setting the VARIANT vresult using VariantInit, and clearing it when we are done with VariantClear, but that didn't help. // JobMgrDll.cpp : Defines the entry point for the DLL application. // #include "stdafx.h" #include "JobMgrDll.h" #include "jobmgr.h" CString gcontext; CString guser; CString ghost; CString glog; JOBMGRDLL_API int nJobMgrDll=0; extern "C" JOBMGRDLL_API char* perform_billcalc(char* cmd, char* context, char* user,char* host,BSTR* log,int* loglen) { char* result = new char[1000]; memset(result,0,999); result[999] = '\0'; bstr_t bt_command = cmd; UUID uuid = __uuidof(BRLib::Rules); VARIANT vresult; char *p_rv; gcontext = context; guser = user; ghost = host; write_log("execute_job"); p_rv = execute_job(uuid, "none", bt_command, &vresult); write_log("DONE execute_job"); CString message; write_log ("Intializing bstr_t with variant"); // WE ALWAYS GET HERE bstr_t res(vresult); //message.Format("%s result = %s",p_rv,res); //write_log(message); write_log("copying Result"); // WE DON'T ALWAYS GET HERE, BUT SOMETIMES WE DO strcpy(result,(char*)res); write_log(CString(result)); *loglen = glog.GetLength(); *log = glog.AllocSysString(); return result; } Again, any ideas much, much appreciated.

    Read the article

  • Bizzare results when running two Visual Studio Express C++ 2008 solutions

    - by Jamie Keeling
    This is a follow on from my previous question although this is about something else. I've been having a problem where for some reason my message that I pass from one process to another only displays the first letter, in this case "M". My application based on a MSDN sample so to make sure I hadn't missed something I create a seperate solution, added the MSDN sample (Without any changes for my needs) and unsuprisingly it works fine. Now for the weird bit, when I run the MSDN sample running (As in debugging) and have my own application running, the text prints out fine without any problems. The second I run my on it's own without the original MSDN sample being open it fails to work and only shows an "M". I've looked in the debugger and don't seem to notice anything suspicious (It's a slightly dated picture, I've fixed the data type inconsistency). Can anyone provide a solution as to this? I've never encountered anything like this before. To look at my source code it's easier to just look at the link I posted at the top of the question, there's no point in me posting it twice. Thank you for any help.

    Read the article

  • How to validate Windows VC++ DLL on Unix systems

    - by Guildencrantz
    I have a solution, mostly C#, but with a few VC++ projects, that is pushed through our standard release process (perl and bash scripts on Unix boxes). Currently the initiative is to validate DLL and EXE versions as they pass through the process. All the versioning is set so that File Version is of the format $Id: $ (between the colon and the second dollar should be a git commit hash), and the Product Version is of the format $Hudson Build: $ (between the colon and the second dollar should be a string representing the hudson build details). Currently this system works extremely well for the C# projects because this version information is stored as plain strings within the compiled code (you can literally use the unix strings command and see the version information); the problem is that the VC++ projects do not expose this information as strings (I have used a windows system to verify that the version information is correctly being set), so I'm not sure how to extract the version on a unix system. Any suggestions for either A) Getting a string representation of the version embedded in the compiled code, or B) A utility/script which can extract this information?

    Read the article

  • Is it possible to get Logged in user Non Restricted token from a service on Vista?

    - by coolcake
    Hello All, I need to create a process with integrity level high, so that it can do all the administrative tasks. But the created process should run in the current logged in desktop i.e. it should not run in session 0. By default only administrators will log on to the console. The service should launch the process, as service is running in session 0 and system account. Can it any how get the non restricted token and use it in CreateProcessAsUser, so that the process created does have integrity level of high or system. Is it possible? One more thing is i should get the non restricted token with out prompting for user name or password of the logged in user. Thanks

    Read the article

  • VC++ how to change a picturebox from header file

    - by JimboJones
    HI, Just ran into a problem. How to I change a picturebox's picture from within a different header file. If I do it in the same .h file as the Form I am working on I use: sq1-Image = bi; (which loads in a bitmap) but when I do it from another header (i've included the correct header file), I get "sq1 is an undeclared identifier" and "left of '-image' must point to a class/struct/union/generic" What I'm looking for is something like Form1::sq1-Image = bi; Basically I just want to point the program to change picturebox from another location....Is this possible? How can I do this? Cheers!

    Read the article

  • On Memory Allocation and C++

    - by Arpan
    And I quote from MSDN http://msdn.microsoft.com/en-us/library/aa366533(VS.85).aspx: The malloc function has the disadvantage of being run-time dependent. The new operator has the disadvantage of being compiler dependent and language dependent. Now the questions folks: a) What do we mean that malloc is run-time dependent? What kind of dynamic memory allocation functions can be independent of run-time? This statement sounds real strange. b) new is language dependent? Of course it should be right? Are HeapAlloc, LocalAlloc etc language independent? c) From a pure performance perspective are the MSVC provided routines preferable? Arpan

    Read the article

  • passin structure form VC++ to C#

    - by Anu
    Hi, im using C# dll in VC++ application.I have somedetails in VC++ like PageNumer pageTitle PageDesc BoxDetail I have to pass this to C# Dll. So i made one structure in VC++,then i pas that to C#.But i could't do that.Pls help mw. VC++ Function: struct SCS3OverVwPg { __int32 iOvrPgNo; char sOvrPgTitle[30]; //OverView Page Title }; void CToolTab::SendOverview() { SCS3OverVwPg *pOverVw = 0; pOverVw = new SCS3OverVwPg; Globals1::gwtoolbar->SetTree(pOverVw); } C# function: public struct SCS3Over { Int32 iOvrPgNo; char[] sOvrPgTitle; } public void SetTree(SCS3Over x) { MessageBox.Show("Data received"); } If i do like this,it shows error error C2664: 'Tabcontrol::ToolBar::SetTree' : cannot convert parameter 1 from 'SCS3OverVwPg *' to 'SCS3Over' IF i change name in C# dll to SCS3OverwPg, it show error of structure redifinition Pls help me.

    Read the article

  • How to set system time, day and year in registry

    - by sijith
    i created new registry entry using RegCreateKeyEx(HKEY_LOCAL_MACHINE, TEXT("Software\XXXXXX\Test"), 0, NULL, 0, 0, NULL, &hkey, &dwDisposition) Now i want to save current system time data and year to the newly created registry for later retrival How can i implement it in VC++ using RegSetKeyValue. I tried but faile dto implement.

    Read the article

  • encryption problem for wlan profile

    - by Jassi
    i am trying to encrypt keyMaterial element from wireless profile. so I want to convert byte array into OLECHAR but it is giving me wrong output not key sea the below code you may know the solution... DATA_BLOB in; DATA_BLOB out; BYTE pin=(BYTE)"FIPL2"; DWORD din=strlen((char*)pin)+1; in.pbData = pin; in.cbData = din; if(CryptProtectData(&in,L"what is it",NULL,NULL,NULL,0,&out)) { BYTE *b=out.pbData; USES_CONVERSION; bstr=SysAllocString(W2BSTR((const WCHAR *)b)); HRCALL(peSubS222->put_text(bstr), ""); SysFreeString(bstr); bstr=NULL; } else { cout<<"NOOOOOOOOOOOOOOOO :("; } what is missing please help me out

    Read the article

  • Write a dll that is accessable from VS 2003 VC++ code

    - by John
    I need to be able to write a DLL in either C# or VC++ that is accessible from code that is written in Visual Studio 2003 VC++. It looks like the code is unmanaged (uses * for pointers) VC++ and this DLL needs to be able to drop right in and be accessed by the current code. The DLL is an RS232 driver that needs to be able to return an int for an error code and pass back, by reference, some measured values, to the calling program. Will I even be able to write this in C#? If not, I only have access to Visual Studio 2005 or 2008. Will I be able to write my code in either, and will that DLL be able to be called from the current code base? Or do I have to go looking on ebay for a copy of VS 2003?

    Read the article

  • Why is C++ fwrite() producing larger output in release?

    - by waffleShirt
    I recently wrote an implementation of the Canonical Huffman compression algorithm. I have a 500kb test file that can be compressed to about 250kb when running the debug and release builds from within Visual Studio 2008. However when I run the release build straight from the executeable the test file only compresses to about 330kb. I am assuming that something is going wrong when the file is written using fwrite(). I have tested the program and confirmed that uncompressing the files always produces the correct uncompressed file. Does anyone know why this could possibly be? How could the same executeable file be producing different sized outputs based on where it is launched from?

    Read the article

  • Boost Include Files in VC++

    - by Dr. K
    For the last few years, I have been exclusively a C# developer. Previously, I developed in C++ and have a C++ application that I built about 3 years ago using VS2005. It made extensive use of the Boost libraries. I recently decided to brush off the old app and rebuild it in VS2008 with the latest version of Boost (the latest version with the "easy" installation program from BoostPro Computing), 1.39. Previously when I had the program running I was at 1.33. Also, the last time the program was running was at least 2 OS installations ago. The Boost installation is located on my machine at: "C:\Program Files\boost\boost_1_39". Anyway, I have done the following: Set the project's "Additional Include Directories" directory to "C:\Program Files\boost\boost_1_39" Added "C:\Program Files\boost\boost_1_39" to VS2008's Tools - Options - Projects and Solutions - VC++ Directories - Include Files I have a number of Boost includes in my stdafx.h file. The compiler fails upon attempting to open the first one - #include <boost/algorithm/string/string.hpp> I have confirmed that the above file is indeed located at "C:\Program Files\boost\boost_1_39\boost\algorithm\string\string.hpp" I continue to get: fatal error C1083: Cannot open include file: 'boost/algorithm/string/string.hpp': No such file or directory Any tips on what else to check would be greatly appreciated. Again, this is an application that compiled fine a few years ago, but the source has now been moved to a new machine/compiler.

    Read the article

  • Want to understand C++ sentry object

    - by Romain Hippeau
    I answered this [question][1] and somebody else had answered as he modern C++ equivalent would be a sentry object: construct it at the beginning of a function, with its constructor implementing call(), and upon return (or abnormal exit), its destructor implements I am not familiar with using sentry objects in C++. I thought they were limited to input and output streams. Could somebody explain to me about C++ sentry objects as well as how to use them as an around interceptor for one or more methods in a class ? [1]: http://stackoverflow.com/questions/2688043/call-return-feature-of-classic-cc-with-classes-what-modern-languages-have-it/2688095#2688095 /

    Read the article

< Previous Page | 7 8 9 10 11 12 13 14 15 16 17 18  | Next Page >