Search Results

Search found 89 results on 4 pages for 'tchar'.

Page 1/4 | 1 2 3 4  | Next Page >

  • Windows C++: LPCTSTR vs const TCHAR

    - by mrl33t
    In my application i'm declaring a string variable near the top of my code to define the name of my window class which I use in my calls to RegisterClassEx, CreateWindowEx etc.. Now, I know that an LPCTSTR is a typedef and will eventually follow down to a TCHAR (well a CHAR or WCHAR depending on whether UNICODE is defined), but I was wondering whether it would be better to use this: static LPCTSTR szWindowClass = TEXT("MyApp"); Or this: static const TCHAR szWindowClass[] = TEXT("MyApp"); I personally prefer the use of the LPCTSTR as coming from a JavaScript, PHP, C# background I never really considered declaring a string as an array of chars. But are there actually any advantages of using one over the other, or does it in fact not even make a difference as to which one I choose? Thank you, in advanced, for your answers.

    Read the article

  • tchar safe functions -- count parameter for UTF-8 constants

    - by Dustin Getz
    I'm porting a library from char to TCHAR. the count parameter of this fragment, according to MSDN, is the number of multibyte characters, not the number of bytes. so, did I get this right? _tcsncmp(access, TEXT("ftp"), 3); //or do i want _tcsnccmp? "Supported on Windows platforms only, _mbsncmp and _mbsnbcmp are multibyte versions of strncmp. _mbsncmp will compare at most count multibyte characters and _mbsnbcmp will compare at most count bytes. They both use the current multibyte code page. _tcsnccmp and _tcsncmp are the corresponding Generic functions for _mbsncmp and _mbsnbcmp, respectively. _tccmp is equivalent to _tcsnccmp."

    Read the article

  • TCHAR end of line character

    - by Xaver
    int DownloadFtpDirectory(TCHAR* DirPath) { WIN32_FIND_DATA FileData; UINT a; TCHAR* APP_NAME = TEXT("ftpcli"); TCHAR* f; int j = 5; do { j++; f = _tcsninc(DirPath, j); }while (_tcsncmp(f, TEXT("/"), 1)); TCHAR* PATH_FTP = wcsncpy(new TCHAR[j], DirPath, j); After the last line gets a string in which there is no line ending character, how to fix this? P.S. how to do so would be out of line "ftp://ftp.microsoft.com/bussys/", get a string ftp.microsoft.com if both strings are TCHAR ?

    Read the article

  • User defined conversion operator as argument for printf

    - by BC
    I have a class that defined a user defined operator for a TCHAR*, like so CMyClass::operator const TCHAR*() const { // returns text as const TCHAR* } I want to be able to do something like CMyClass myClass; _tprintf(_T("%s"), myClass); or even _tprintf(_T("%s"), CMyClass(value)); But when trying, printf always prints (null) instead of the value. I have also tried a normal char* operator, as well variations with const etc. It only works correctly if I explicitly call the operator or do a cast, like _tprintf(_T("%s\n"), (const TCHAR*)myClass); _tprintf(_T("%s\n"), myClass.operator const TCHAR *()); However, I don't want to cast. How can this be achieved? Note, that a possibility is to create a function that has a parameter of const TCHAR*, so that it forcible calls the operator TCHAR*, but this I also don't want to implement.

    Read the article

  • Why is there garbage in my TCHAR, even after ZeroMemory()?

    - by samoz
    I have inherited the following line of code: TCHAR temp[300]; GetModuleFileName(NULL, temp, 300); However, this fails as the first 3 bytes are filled with garbage values (always the same ones though, -128, -13, 23, in that order). I said, well fine and changed it to: TCHAR temp[300]; ZeroMemory(temp, 300); GetModuleFileName(NULL, temp, 300); but the garbage values persisted! Can someone explain what is going on and how to fix it?

    Read the article

  • Convert TCHAR* argv[]

    - by sijith
    i want to enter a text into TCHAR* argv[], how its possible to do. OR how to convert from a charater to TCHAR* argv[]. Please help char randcount[]="Hello world"; want to convert to TCHAR* argv[]

    Read the article

  • LPCSTR, TCHAR, String

    - by user285327
    I am use next type of strings: LPCSTR, TCHAR, String i want to convert: 1) from TCHAR to LPCSTR 2) from String to char I convert from TCHAR to LPCSTR by that code: RunPath = TEXT("C:\\1"); LPCSTR Path = (LPCSTR)RunPath; From String to char i convert by that code: SaveFileDialog^ saveFileDialog1 = gcnew SaveFileDialog; saveFileDialog1->Title = "?????????? ?????-????????"; saveFileDialog1->Filter = "bck files (*.bck)|*.bck"; saveFileDialog1->RestoreDirectory = true; pin_ptr<const wchar_t> wch = TEXT(""); if ( saveFileDialog1->ShowDialog() == System::Windows::Forms::DialogResult::OK ) { wch = PtrToStringChars(saveFileDialog1->FileName); } else return; ofstream os(wch, ios::binary); My problem is that when i set "Configuration Properties - General Character Set in "Use Multi-Byte Character Set" the first part of code work correctly. But the second part of code return error C2440. When i set "Configuration Properties - General Character Set in "Use Unicode" the second part of code work correctly. But the first part of code return the only first character from TCHAR to LPCSTR.

    Read the article

  • C++ template function specialization using TCHAR on Visual Studio 2005

    - by Eli
    I'm writing a logging class that uses a templatized operator<< function. I'm specializing the template function on wide-character string so that I can do some wide-to-narrow translation before writing the log message. I can't get TCHAR to work properly - it doesn't use the specialization. Ideas? Here's the pertinent code: // Log.h header class Log { public: template <typename T> Log& operator<<( const T& x ); template <typename T> Log& operator<<( const T* x ); template <typename T> Log& operator<<( const T*& x ); ... } template <typename T> Log& Log::operator<<( const T& input ) { printf("ref"); } template <typename T> Log& Log::operator<<( const T* input ) { printf("ptr"); } template <> Log& Log::operator<<( const std::wstring& input ); template <> Log& Log::operator<<( const wchar_t* input ); And the source file // Log.cpp template <> Log& Log::operator<<( const std::wstring& input ) { printf("wstring ref"); } template <> Log& Log::operator<<( const wchar_t* input ) { printf("wchar_t ptr"); } template <> Log& Log::operator<<( const TCHAR*& input ) { printf("tchar ptr ref"); } Now, I use the following test program to exercise these functions // main.cpp - test program int main() { Log log; log << "test 1"; log << L"test 2"; std::string test3( "test3" ); log << test3; std::wstring test4( L"test4" ); log << test4; TCHAR* test5 = L"test5"; log << test4; } Running the above tests reveals the following: // Test results ptr wchar_t ptr ref wstring ref ref Unfortunately, that's not quite right. I'd really like the last one to be "TCHAR", so that I can convert it. According to Visual Studio's debugger, the when I step in to the function being called in test 5, the type is wchar_t*& - but it's not calling the appropriate specialization. Ideas? I'm not sure if it's pertinent or not, but this is on a Windows CE 5.0 device.

    Read the article

  • print TCHAR[] on console

    - by hara
    Hi I'm quite sure that it is a stupid issue but it drives me crazy.. how could i print on the console a TCHAR array? DWORD error = WSAGetLastError(); TCHAR errmsg[512]; int ret = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, 0, error, 0, errmsg, 511, NULL); i need to print errmsg...

    Read the article

  • How to deal with Unicode strings in C/C++ in a cross-platform friendly way?

    - by Sorin Sbarnea
    On platforms different than Windows you could easily use char * strings and treat them as UTF-8. The problem is that on Windows you are required to accept and send messages using wchar* strings (W). If you'll use the ANSI functions (A) you will not support Unicode. So if you want to write truly portable application you need to compile it as Unicode on Windows. Now, In order to keep the code clean I would like to see what is the recommended way of dealing with strings, a way that minimize ugliness in the code. Type of strings you may need: std::string, std::wstring, std::tstring,char *,wchat_t *, TCHAR*, CString (ATL one). Issues you may encounter: cout/cerr/cin and their Unicode variants wcout,wcerr,wcin all renamed wide string functions and their TCHAR macros - like strcmp, wcscmp and _tcscmp. constant strings inside code, with TCHAR you will have to fill your code with _T() macros. What approach do you see as being best? (examples are welcome) Personally I would go for a std::tstring approach but I would like to see how would do to the conversions where they are necessary.

    Read the article

  • How can I dial GPRS/EDGE in Win CE

    - by brontes
    Hello all. I am developing application in python on Windows CE which needs connection to the internet (via GPRS/EDGE). When I turn on the device, the internet connection is not active. It becomes active if I open internet explorer. I would like to activate connection in my application. I'm trying to do this with RasDial function over ctypes library, but I can't get it to work. Is this the right way or I should do something else? Below is my current code. The ResDial function keeps returning error 87 – Invalid parameter. I don't know anymore what is wrong with it. I would really appreciate any kind of help. Thanks in advance. encoding: utf-8 import ppygui as gui from ctypes import * import os class MainFrame(gui.CeFrame): def init(self, parent = None): gui.CeFrame.init(self, title=u"Zgodovina dokumentov", menu="Menu") DWORD = c_ulong TCHAR = c_wchar ULONG_PTR = c_ulong class RASDIALPARAMS(Structure): _fields_ = [("dwSize", DWORD), ("szEntryName", TCHAR*21), ("szPhoneNumber", TCHAR*129), ("szCallbackNumber", TCHAR*49), ("szUserName", TCHAR*257), ("szPassword", TCHAR*257), ("szDomain", TCHAR*16), ] try: param = RASDIALPARAMS() param.dwSize = 1462 # also tried 1464 and sizeof(RASDIALPARAMS()). Makes no difference. param.szEntryName = u"My Connection" param.szPhoneNumber = u"0" param.szCallbackNumber = u"0" param.szUserName = u"0" param.szPassword = u"0" param.szDomain = u"0" iNasConn = c_ulong(0) ras = windll.coredll.RasDial(None, None, param, c_ulong(0xFFFFFFFF), c_voidp(self._w32_hWnd), byref(iNasConn)) print ras, repr(iNasConn) #this prints 87 c_ulong(0L) except Exception, e: print "Error" print e if name == 'main': app = gui.Application(MainFrame(None)) # create an application bound to our main frame instance app.run() #launch the app !

    Read the article

  • Array of datas returning issue, Overwriting

    - by sijith
    Hi, Please help me on this Here i want to save the converted data into new pointers. But everytime the data is overwriting with most recent data. Please check my code TCHAR nameBuffer[256]; //Globally Declared void Caller() { TCHAR* ptszSecondInFile= QStringToTCharBuffer(userName); TCHAR* ptszOutFile=QStringToTCharBuffer(Destinationfilename); } TCHAR *dllmerge::QStringToTCharBuffer( QString buffer ) { memset(nameBuffer, 0, sizeof(nameBuffer)); #if UNICODE _tcscpy_s(nameBuffer, _countof(nameBuffer), buffer.toUtf8()); #else _tcscpy_s(nameBuffer, _countof(nameBuffer), buffer.toLocal8Bit()); #endif _tprintf( _T( "nameBuffer %s\n" ), nameBuffer ); return nameBuffer; } I am gettting ptszSecondInFile and ptszOutFile both same answer. Is it possible to do with TCHAR* nameBuffer[256];

    Read the article

  • Windows CE: Using IOCTL_DISK_GET_STORAGEID

    - by Bruce Eitman
    A customer approached me recently to ask if I had any code that demonstrated how to use STORAGE_IDENTIFICATION, which is the data structure used to get the Storage ID from a disk. I didn’t have anything, which of course sends me off writing code and blogging about it. Simple enough, right? Go read the documentation for STORAGE_IDENTIFICATION which lead me to IOCTL_DISK_GET_STORAGEID. Except that the documentation for IOCTL_DISK_GET_STORAGEID seems to have a problem.   The most obvious problem is that it shows how to call CreateFile() to get the handle to use with DeviceIoControl(), but doesn’t show how to call DeviceIoControl(). That is odd, but not really a problem. But, the call to CreateFile() seems to be wrong, or at least it was in my testing. The documentation shows the call to be: hVolume = CreateFile(TEXT("\Storage Card\Vol:"), GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL); I tried that, but my testing with an SD card mounted as Storage Card failed on the call to CreateFile(). I tried several variations of this, but none worked. Then I remembered that some time ago I wrote an article about enumerating the disks (Windows CE: Displaying Disk Information). I pulled up that code and tried again with both the disk device name and the partition volume name. The disk device name worked. The device names are DSKx:, where x is the disk number. I created the following function to output the Manufacturer ID and Serial Number returned from IOCTL_DISK_GET_STORAGEID:   #include "windows.h" #include "Diskio.h"     BOOL DisplayDiskID( TCHAR *Disk ) {                 STORAGE_IDENTIFICATION *StoreID = NULL;                 STORAGE_IDENTIFICATION GetSizeStoreID;                 DWORD dwSize;                 HANDLE hVol;                 TCHAR VolumeName[MAX_PATH];                 TCHAR *ManfID;                 TCHAR *SerialNumber;                 BOOL RetVal = FALSE;                 DWORD GLE;                   // Note that either of the following works                 //_stprintf(VolumeName, _T("\\%s\\Vol:"), Disk);                 _stprintf(VolumeName, _T("\\%s"), Disk);                   hVol = CreateFile( Disk, GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);                   if( hVol != INVALID_HANDLE_VALUE )                 {                                 if(DeviceIoControl(hVol, IOCTL_DISK_GET_STORAGEID, (LPVOID)NULL, 0, &GetSizeStoreID, sizeof(STORAGE_IDENTIFICATION), &dwSize, NULL) == FALSE)                                 {                                                 GLE = GetLastError();                                                 if( GLE == ERROR_INSUFFICIENT_BUFFER )                                                 {                                                                 StoreID = (STORAGE_IDENTIFICATION *)malloc( GetSizeStoreID.dwSize );                                                                 if(DeviceIoControl(hVol, IOCTL_DISK_GET_STORAGEID, (LPVOID)NULL, 0, StoreID, GetSizeStoreID.dwSize, &dwSize, NULL) != FALSE)                                                                 {                                                                                 RETAILMSG( 1, (TEXT("DisplayDiskID: Flags %X\r\n"), StoreID->dwFlags ));                                                                                 if( !(StoreID->dwFlags & MANUFACTUREID_INVALID) )                                                                                 {                                                                                                 ManfID = (TCHAR *)((DWORD)StoreID + StoreID->dwManufactureIDOffset);                                                                                                 RETAILMSG( 1, (TEXT("DisplayDiskID: Manufacture ID %s\r\n"), ManfID ));                                                                                 }                                                                                 if( !(StoreID->dwFlags & SERIALNUM_INVALID) )                                                                                 {                                                                                                 SerialNumber = (TCHAR *)((DWORD)StoreID + StoreID->dwSerialNumOffset);                                                                                                 RETAILMSG( 1, (TEXT("DisplayDiskID: Serial Number %s\r\n"), SerialNumber ));                                                                                 }                                                                                 RetVal = TRUE;                                                                 }                                                                 else                                                                                 RETAILMSG( 1, (TEXT("DisplayDiskID: DeviceIoControl failed (%d)\r\n"), GLE));                                                                                                                                                 free(StoreID);                                                 }                                                 else                                                                 RETAILMSG( 1, (TEXT("No Disk Identifcation available for %s\r\n"), VolumeName ));                                 }                                 else                                                 RETAILMSG( 1, (TEXT("DisplayDiskID: DeviceIoControl succeeded (and shouldn't have)\r\n")));                                                                                 CloseHandle (hVol);                 }                 else                                 RETAILMSG( 1, (TEXT("DisplayDiskID: Failed to open volume (%s)\r\n"), VolumeName ));                   return RetVal; } Further testing showed that both \DSKx: and \DSKx:\Vol: work when calling CreateFile();   Copyright © 2010 – Bruce Eitman All Rights Reserved

    Read the article

  • c++ / c confusion

    - by mrbuxley
    Im trying to make a small app in c++ that saves midifiles with this library. http://musicnote.sourceforge.net/docs/html/index.html The sample code that is given on the homepage looks like this. #include "MusicNoteLib.h" void main() { MusicNoteLib::Player player; // Create the Player Object player.Play("C D E F G A B"); // Play the Music Notes on the default MIDI output port } This piece of code won't compile in Visual studio 2008, I get many errors like MusicNoteLib.h(22) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int I don't understand the error or where to start looking... There also was some dll files that can be used instead of this h file. #ifndef __MUSICNOTE_LIB_H__EBEE094C_FF6E_43a1_A6CE_D619564F9C6A__ #define __MUSICNOTE_LIB_H__EBEE094C_FF6E_43a1_A6CE_D619564F9C6A__ /** @file MusicNoteLib.h * \brief Main header file for accessing the MusicNote Library */ /// <Summary> /// This header file can be included directly in your project or through /// MusicNoteLib.h of the MusicNoteDll project. If included directly, this /// will be built directly as a satic library. If included through MusicNoteDll /// this will use dllImports through MUSICNOTELIB_API /// </Summary> #ifndef MUSICNOTELIB_API #define MUSICNOTELIB_API #endif // MUSICNOTELIB_API //#include "Player.h" namespace MusicNoteLib /// Music Programming Library { typedef void (__stdcall *LPFNTRACEPROC)(void* pUserData, const TCHAR* szTraceMsg); typedef void (__stdcall *LPFNERRORPROC)(void* pUserData, long lErrCode, const TCHAR* szErrorMsg, const TCHAR* szToken); extern "C" { MUSICNOTELIB_API typedef void MStringPlayer; MUSICNOTELIB_API void* GetCarnaticMusicNoteReader(); /// <Summary> /// Creates a MusicString Player object. /// </Summary> MUSICNOTELIB_API MStringPlayer* CreateMusicStringPlayer(); /// <Summary> /// Plays Music string notes on the default MIDI Output device with the default Timer Resolution. /// Use PlayMusicStringWithOpts() to use custom values. /// @param szMusicNotes the Music string to be played on the MIDI output device /// @return True if the notes were played successfully, False otherwise /// </Summary> MUSICNOTELIB_API bool PlayMusicString(const TCHAR* szMusicNotes); /// <Summary> /// Same as PlayMusicString() except that this method accepts Callbacks. /// The Trace and Error callbacks will be used during the Parse of the Music Notes. /// @param szMusicNotes the Music string to be played on the MIDI output device /// @param traceCallbackProc the Callback to used to report Trace messages /// @param errorCallbackProc the Callback to used to report Error messages /// @param pUserData any user supplied data that should be sent to the Callback /// @return True if the notes were played successfully, False otherwise /// </Summary> MUSICNOTELIB_API bool PlayMusicStringCB(const TCHAR* szMusicNotes, LPFNTRACEPROC traceCallbackProc, LPFNERRORPROC errorCallbackProc, void* pUserData); /// <Summary> /// Plays Music string notes on the given MIDI Output device using the given Timer Resolution. /// Use PlayMusicString() to use default values. /// @param szMusicNotes the Music notes to be played /// @param nMidiOutPortID the device ID of the MIDI output port to be used for the play /// @param nTimerResMS preferred MIDI timer resolution, in MilliSeconds /// @return True if Play was successful, False otherwise /// </Summary> MUSICNOTELIB_API bool PlayMusicStringWithOpts(const TCHAR* szMusicNotes, int nMidiOutPortID, unsigned int nTimerResMS); /// <Summary> /// Same as PlayMusicStringWithOpts() except that this method accepts Callbacks. /// The Trace and Error callbacks will be used during the Parse of the Music Notes. /// @param szMusicNotes the Music notes to be played /// @param nMidiOutPortID the device ID of the MIDI output port to be used for the play /// @param nTimerResMS preferred MIDI timer resolution, in MilliSeconds /// @param traceCallbackProc the Callback to used to report Trace messages /// @param errorCallbackProc the Callback to used to report Error messages /// @param pUserData any user supplied data that should be sent to the Callback /// @return True if Play was successful, False otherwise /// </Summary> MUSICNOTELIB_API bool PlayMusicStringWithOptsCB(const TCHAR* szMusicNotes, int nMidiOutPortID, unsigned int nTimerResMS, LPFNTRACEPROC traceCallbackProc, LPFNERRORPROC errorCallbackProc, void* pUserData); /// <Summary> /// Save the given MusicString content into a MIDI output file /// @param szMusicNotes Music Notes to be converted to MIDI output /// @param szOutputFilePath path of the MIDI output file /// @return True if the the content was saved successfully, False otherwise /// </Summary> MUSICNOTELIB_API bool SaveAsMidiFile(const TCHAR* szMusicNotes, const char* szOutputFilePath); //MUSICNOTELIB_API typedef void (*ParseErrorProc)(const MusicNoteLib::CParser*, MusicNoteLib::CParser::ErrorEventHandlerArgs* pEvArgs); //MUSICNOTELIB_API typedef void (*ParseTraceProc)(const MusicNoteLib::CParser*, MusicNoteLib::CParser::TraceEventHandlerArgs* pEvArgs); MUSICNOTELIB_API void Parse(const TCHAR* szNotes, LPFNTRACEPROC traceCallbackProc, void* pUserData); } // extern "C" } // namespace MusicNoteLib #endif // __MUSICNOTE_LIB_H__EBEE094C_FF6E_43a1_A6CE_D619564F9C6A__

    Read the article

  • Problem with FtpFindFirstFile

    - by Xaver
    I want to download all file from ftp directory i want use for that FtpFindFirstFile and FtpGetFile; LPWIN32_FIND_DATA FileData; TCHAR* APP_NAME = TEXT("ftpcli"); TCHAR* PATH_FTP = TEXT("ftp://127.0.01"); TCHAR* ADR_FTP = TEXT("127.0.0.1"); TCHAR* LC_FILE = TEXT("C:\\!"); TCHAR* PATH_FILE = TEXT("/Soft/DVD_Players/WinDVD6"); UINT a; HINTERNET opn; HINTERNET conn; a = InternetAttemptConnect(0); if (a == ERROR_SUCCESS ) { if(InternetCheckConnection(PATH_FTP,FLAG_ICC_FORCE_CONNECTION, NULL)) { opn = InternetOpen(APP_NAME, INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, INTERNET_FLAG_ASYNC); conn = InternetConnect(opn, ADR_FTP, INTERNET_DEFAULT_FTP_PORT, NULL, NULL, INTERNET_SERVICE_FTP, NULL, NULL); FtpSetCurrentDirectory(conn, PATH_FILE); FtpFindFirstFile(conn, NULL, &FileData, INTERNET_FLAG_NEED_FILE, NULL); FtpGetFile(conn, FileData->cFileName, LC_FILE, FALSE, FILE_ATTRIBUTE_NORMAL, FTP_TRANSFER_TYPE_BINARY, NULL); } } That code return error i know that because i do not identified memory on LPWIN32_FIND_DATA. But i do not know how do it.

    Read the article

  • header confusion. Compiler not recognizing datatypes

    - by numerical25
    I am getting confused on why the compiler is not recognizing my classes. So I am just going to show you my code and let you guys decide. My error is this error C2653: 'RenderEngine' : is not a class or namespace name and it's pointing to this line std::vector<RenderEngine::rDefaultVertex> m_verts; Here is the code for rModel, in its entirety. It contains the varible. the class that holds it is further down. #ifndef _MODEL_H #define _MODEL_H #include "stdafx.h" #include <vector> #include <string> //#include "RenderEngine.h" #include "rTri.h" class rModel { public: typedef tri<WORD> sTri; std::vector<sTri> m_tris; std::vector<RenderEngine::rDefaultVertex> m_verts; std::wstring m_name; ID3D10Buffer *m_pVertexBuffer; ID3D10Buffer *m_pIndexBuffer; rModel( const TCHAR *filename ); rModel( const TCHAR *name, int nVerts, int nTris ); ~rModel(); float GenRadius(); void Scale( float amt ); void Draw(); //------------------------------------ Access functions. int NumVerts(){ return m_verts.size(); } int NumTris(){ return m_tris.size(); } const TCHAR *Name(){ return m_name.c_str(); } RenderEngine::cDefaultVertex *VertData(){ return &m_verts[0]; } sTri *TriData(){ return &m_tris[0]; } }; #endif at the very top of the code there is a header file #include "stdafx.h" that includes this // stdafx.h : include file for standard system include files, // or project specific include files that are used frequently, but // are changed infrequently // #include "targetver.h" #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers // Windows Header Files: #include <windows.h> // C RunTime Header Files #include <stdlib.h> #include <malloc.h> #include <memory.h> #include <tchar.h> #include "resource.h" #include "d3d10.h" #include "d3dx10.h" #include "dinput.h" #include "RenderEngine.h" #include "rModel.h" // TODO: reference additional headers your program requires here as you can see, RenderEngine.h comes before rModel.h #include "RenderEngine.h" #include "rModel.h" According to my knowledge, it should recognize it. But on the other hand, I am not really that great with organizing headers. Here my my RenderEngine Declaration. #pragma once #include "stdafx.h" #define MAX_LOADSTRING 100 #define MAX_LIGHTS 10 class RenderEngine { public: class rDefaultVertex { public: D3DXVECTOR3 m_vPosition; D3DXVECTOR3 m_vNormal; D3DXCOLOR m_vColor; D3DXVECTOR2 m_TexCoords; }; class rLight { public: rLight() { } D3DXCOLOR m_vColor; D3DXVECTOR3 m_vDirection; }; static HINSTANCE m_hInst; HWND m_hWnd; int m_nCmdShow; TCHAR m_szTitle[MAX_LOADSTRING]; // The title bar text TCHAR m_szWindowClass[MAX_LOADSTRING]; // the main window class name void DrawTextString(int x, int y, D3DXCOLOR color, const TCHAR *strOutput); //static functions static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); static INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam); bool InitWindow(); bool InitDirectX(); bool InitInstance(); int Run(); void ShutDown(); void AddLight(D3DCOLOR color, D3DXVECTOR3 pos); RenderEngine() { m_screenRect.right = 800; m_screenRect.bottom = 600; m_iNumLights = 0; } protected: RECT m_screenRect; //direct3d Members ID3D10Device *m_pDevice; // The IDirect3DDevice10 // interface ID3D10Texture2D *m_pBackBuffer; // Pointer to the back buffer ID3D10RenderTargetView *m_pRenderTargetView; // Pointer to render target view IDXGISwapChain *m_pSwapChain; // Pointer to the swap chain RECT m_rcScreenRect; // The dimensions of the screen ID3D10Texture2D *m_pDepthStencilBuffer; ID3D10DepthStencilState *m_pDepthStencilState; ID3D10DepthStencilView *m_pDepthStencilView; //transformation matrixs system D3DXMATRIX m_mtxWorld; D3DXMATRIX m_mtxView; D3DXMATRIX m_mtxProj; //pointers to shaders matrix varibles ID3D10EffectMatrixVariable* m_pmtxWorldVar; ID3D10EffectMatrixVariable* m_pmtxViewVar; ID3D10EffectMatrixVariable* m_pmtxProjVar; //Application Lights rLight m_aLights[MAX_LIGHTS]; // Light array int m_iNumLights; // Number of active lights //light pointers from shader ID3D10EffectVectorVariable* m_pLightDirVar; ID3D10EffectVectorVariable* m_pLightColorVar; ID3D10EffectVectorVariable* m_pNumLightsVar; //Effect members ID3D10Effect *m_pDefaultEffect; ID3D10EffectTechnique *m_pDefaultTechnique; ID3D10InputLayout* m_pDefaultInputLayout; ID3DX10Font *m_pFont; // The font used for rendering text // Sprites used to hold font characters ID3DX10Sprite *m_pFontSprite; ATOM RegisterEngineClass(); void DoFrame(float); bool LoadEffects(); void UpdateMatrices(); void UpdateLights(); }; The classes are defined within the class class rDefaultVertex { public: D3DXVECTOR3 m_vPosition; D3DXVECTOR3 m_vNormal; D3DXCOLOR m_vColor; D3DXVECTOR2 m_TexCoords; }; class rLight { public: rLight() { } D3DXCOLOR m_vColor; D3DXVECTOR3 m_vDirection; }; Not sure if thats good practice, but I am just going by the book. In the end, I just need a good way to organize it so that rModel recognizes RenderEngine. and if possible, the other way around.

    Read the article

  • Are the *A Win32 API calls still relevant?

    - by Thanatos
    I still see advice about using the LPTSTR/TCHAR types, etc., instead of LPWSTR/WCHAR. I believe the Unicode stuff was well introduced at Win2k, and I frankly don't write code for Windows 98 anymore. (Excepting special cases, of course.) Given that I don't care about Windows 98 (or, even less, ME) as they're decade old OS, is there any reason to use the compatibility TCHAR, etc. types? Why still advise people to use TCHAR - what benefit does it add over using WCHAR directly?

    Read the article

  • Using Windows header files within Netbeans 6.8

    - by Matthieu Steffens
    I'm trying to make an windows application within Netbeans. When using Visual studio it is no problem to use files like tchar.h I have receaved a basic file structure containing those and I'm trying to get them to work on Netbeans IDE but it seems that Netbeans won't allow using files from Visual Studio. I have tried to add the tchar.h file and all other file it required (including some C++ core files) and commenting the errors written in those care files: #error ERROR: Use of C runtime library internal header file. But netbenas can't find the tchar.h file while being in same folder...

    Read the article

  • Can I use a static var to "cache" the result? C++

    - by flyout
    I am using a function that returns a char*, and right now I am getting the compiler warning "returning address of local variable or temporary", so I guess I will have to use a static var for the return, my question is can I make something like if(var already set) return var else do function and return var? This is my function: char * GetUID() { TCHAR buf[20]; StringCchPrintf(buf, 20*sizeof(char), TEXT("%s"), someFunction()); return buf; } And this is what I want to do: char * GetUID() { static TCHAR buf[20]; if(strlen(buf)!=0) return buf; StringCchPrintf(buf, 20*sizeof(char), TEXT("%s"), someFunction()); return buf; } Is this a well use of static vars? And should I use ZeroMemory(&buf, 20*sizeof(char))? I removed it because if I use it above the if(strlen...) my TCHAR length is never 0, should I use it below?

    Read the article

  • Windows CE: Changing Static IP Address

    - by Bruce Eitman
    A customer contacted me recently and asked me how to change a static IP address at runtime.  Of course this is not something that I know how to do, but with a little bit of research I figure out how to do it. It turns out that the challenge is to request that the adapter update itself with the new IP Address.  Otherwise, the change in IP address is a matter of changing the address in the registry for the adapter.   The registry entry is something like: [HKEY_LOCAL_MACHINE\Comm\LAN90001\Parms\TcpIp]    "EnableDHCP"=dword:0    "IpAddress"="192.168.0.100"     "DefaultGateway"="192.168.0.1"    "Subnetmask"="255.255.255.0" Where LAN90001 would be replace with your adapter name.  I have written quite a few articles about how to modify the registry, including a registry editor that you could use. Requesting that the adapter update itself is a matter of getting a handle to the NDIS driver, and then asking it to refresh the adapter.  The code is: #include <windows.h> #include "winioctl.h" #include "ntddndis.h"   void RebindAdapter( TCHAR *adaptername ) {       HANDLE hNdis;       BOOL fResult = FALSE;       int count;         // Make this function easier to use - hide the need to have two null characters.       int length = wcslen(adaptername);       int AdapterSize = (length + 2) * sizeof( TCHAR );       TCHAR *Adapter = malloc(AdapterSize);       wcscpy( Adapter, adaptername );       Adapter[ length ] = '\0';       Adapter[ length +1 ] = '\0';           hNdis = CreateFile(DD_NDIS_DEVICE_NAME,                   GENERIC_READ | GENERIC_WRITE,                   FILE_SHARE_READ | FILE_SHARE_WRITE,                   NULL,                   OPEN_ALWAYS,                   0,                   NULL);         if (INVALID_HANDLE_VALUE != hNdis)       {             fResult = DeviceIoControl(hNdis,                         IOCTL_NDIS_REBIND_ADAPTER,                         Adapter,                         AdapterSize,                         NULL,                         0,                         &count,                         NULL);             if( !fResult )             {                   RETAILMSG( 1, (TEXT("DeviceIoControl failed %d\n"), GetLastError() ));             }             CloseHandle(hNdis);       }       else       {             RETAILMSG( 1, (TEXT("Failed to open NDIS Handle\n")));       }   }       int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR    lpCmdLine, int       nCmdShow) {     RebindAdapter( TEXT("LAN90001") );     return 0; }   If you don’t want to write any code, but instead plan to use a registry editor to change the IP Address, then there is a command line utility to do the same thing.  NDISConfig.exe can be used: Ndisconfig adapter rebind LAN90001    Copyright © 2012 – Bruce Eitman All Rights Reserved

    Read the article

  • Why is the exception thrown on memcpy using during copying LPBYTE to LPTSTR (clipboard)?

    - by user46503
    Hello, I have a LPBYTE array (taken from file) and I need to copy it into LPTSRT (actually into the clipboard). The trouble is copying work but unstable, sometime an exception was thrown (not always) and I don't understand why. The code is: FILE *fConnect = _wfopen(connectFilePath, _T("rb")); if (!fConnect) return; fseek(fConnect, 0, SEEK_END); lSize = ftell(fConnect); rewind(fConnect); LPBYTE lpByte = (LPBYTE) malloc(lSize); fread(lpByte, 1, lSize, fConnect); lpByte[lSize] = 0; fclose(fConnect); //Copy into clipboard BOOL openRes = OpenClipboard(NULL); if (!openRes) return; DWORD err = GetLastError(); EmptyClipboard(); HGLOBAL hText; hText = GlobalAlloc(GMEM_MOVEABLE, (lSize+ sizeof(TCHAR))); LPTSTR sMem = (TCHAR*)GlobalLock(hText); memcpy(sMem, lpByte, (lSize + sizeof(TCHAR))); The last string is the place where the exception is thrown. Thanks a lot

    Read the article

1 2 3 4  | Next Page >