Asscotte's Profile User Rating: -----

Reputation: 35 Craftsman
Group:
Authors
Active Posts:
610 (0.32 per day)
Joined:
08-February 09
Profile Views:
11,689
Last Active:
User is offline Jul 17 2012 11:58 AM
Currently:
Offline

Previous Fields

Country:
Who Cares
OS Preference:
Windows
Favorite Browser:
FireFox
Favorite Processor:
Intel
Favorite Gaming Platform:
Playstation
Your Car:
Who Cares
Dream Kudos:
425

Latest Visitors

Icon   Asscotte has not set their status

Posts I've Made

  1. In Topic: Bad Type Conversion Somewhere

    Posted 16 Jul 2012

    I'm really confused now, what is with this unicode stuff.

    Okay, from what I understand, the problem with the first code is that I was actually passing pointer locations so was getting numbers as the result, which obviously weren't valid file names.

    The problem I am now getting is how to correctly get from
    char
    
    or
    std::string
    
    to
    TCHAR
    
    or
    LPCTSTR
    


    Since technically LPCTSTR is just a TCHAR pointer, I think, I just don't understand how it works. I tried converting char[] to TCHAR[] with the following code:

    	TCHAR* ConvertTCHAR(char Char[])
    		{
    			USES_CONVERSION;
    			TCHAR* b = A2T(Char);
    			return b;
    
    		}
    
    


    But I don't think that this is that clean.

    Anyway, according to the website that I mentioned in my previous post:

    #define  LPCTSTR        const TCHAR* 
    
    


    Since that is what I want, shouldn't this function be returning, essentially, what I want?

    If so where is my confusion with pointers, because somewhere else said that std::string was a char[]*

    ahhhh... so confused.

    Anyway be, below is the code I have tried and failed to use.

    	char* CombineChar(char* Char1, char* Char2)
    	{
    		char* mHeader = Char1;
    		// retrieve incoming string and assign to variable
    		char* msgHeader = new char[strlen(Char2)+1];
    		memcpy(msgHeader,Char2,strlen(Char2)+1);
    		msgHeader[strlen( Char2 )] = '\0';
    
    		char* retVal = new char[strlen(mHeader)+strlen(msgHeader)+1];
    		*retVal = '\0';
    		
    		// Assemble the string
    		strcat(retVal,mHeader);
    		strcat(retVal,msgHeader);
    
    		return retVal;
    	}
    
    		TCHAR* ConvertTCHAR(char Char[])
    		{
    			USES_CONVERSION;
    			TCHAR* b = A2T(Char);
    			return b;
    
    		}
    
    	void AllDrives_Test(char SPath[])
    	{
    					char Letters[25] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','y','z'};
    					int i;
    			
    	
    			for(i= 0; i < 25; i++){
    				
    				string* PP = Letters[i] + SPath;
    				ConvertTCHAR(PP);
    				LPCTSTR Iglo = (TCHAR*)PP.c_str();
    				char Ni[] = Letters[i];
    				char Path = CombineChar(Ni ,SPath);
    				LPCTSTR PathI = (PP);
    				cout << PathI;
    
    
    			/*
    
    
    				cout << "\n Attempting Path: ";
    				cout << FullPath;
    					CString _Path=_T("f");
    					 LPCTSTR Path = _Path;
    					
    					 if (_access (FPath, 0) != 0) {
    						 cout << "F1";
    						 break;
    			}
    					 cout << "F2";
    					 // File Exists and we are able to modify.
    					 (CopyFile(FullPath,FullPath + OldTag,false)); // Rename from file.xxx to file.xxx.old
    					 CFile::Remove(FullPath); // Delete old path.
    					 (CopyFile(InPath,FullPath,false)); // Copy from local to remote drive.
    					 //done
    					 */
    				break;
    			}
    
    



    (Note: I switched to a multibyte build to see if it would make a difference. It didn't.)

    Apon reflection this is in the wrong place. It should be in the C/C++ forum, its not .net. Whoops. Sorry. Could this be moved?
  2. In Topic: Bad Type Conversion Somewhere

    Posted 16 Jul 2012

    I am getting closer to understanding. For all those in the same situation, the issue relies on my understanding of LPCTSTR, and what it is. There is a useful article here that could help you understand. Will post a solution when I can.

My Information

Member Title:
D.I.C Addict
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:
Interests:
Sport
Years Programming:
2
Programming Languages:
VB.net 80% - 90% , Some C# 35% - 40%, Some C++ 1%, Batch 70%

Contact Information

E-mail:
Private
Website URL:
Website URL  http://

Friends

Comments

Asscotte has no profile comments yet. Why not say hello?