Results 1 to 8 of 8

Thread: Lpwstr

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2000
    Location
    Birmingham, AL
    Posts
    1,276

    Lpwstr

    I have a LPWSTR with a value and I want to convert it to char* or string.

    Is there a simple function to do this?
    Last edited by wey97; Jun 14th, 2002 at 12:28 AM.

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    LPWSTR is actually wchar_t* (or the equivalent of).

    You can use this raw under 2000 (it's a Unicode string), but for 98 you need to convert it. Search the forum for WideCharToMultiByte and you should be sorted
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2000
    Location
    Birmingham, AL
    Posts
    1,276
    Originally posted by parksie
    You can use this raw under 2000
    Ok, I am in 2000, so how do I do this?

  4. #4
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    What are you using? Is it a console app?

    I think you can just output it to wcout in the usual manner. It's hazy trying to use both in one program, though - either convert everything to Unicode, or everything to the multibyte set (the normal char* stuff...yes I know it's called multibyte but for most characters 1 byte will suffice).
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2000
    Location
    Birmingham, AL
    Posts
    1,276

    Talking

    It is in console for now.

    To be honest with you, I am in a bit of a mess. I am trying to enumerate the Protected Storage in W2K like here http://www.codeproject.com/w2k/pseenuma.asp

    Here is the code I have so far.
    Code:
    
    #include <windows.h>
    #include <iostream>
    using namespace std;
    
    
    // import type library.
    #import <pstorec.dll> no_namespace
    
    // function pointer
    typedef HRESULT (WINAPI *PStoreCreateInstancePtr)(IPStore **, DWORD, DWORD, DWORD);
    
    
    void main(){
    
    	CoInitialize(NULL);
    	
    	HMODULE hPstoreDLL;
    	
    	hPstoreDLL = LoadLibrary("pstorec.dll");
    	
    	PStoreCreateInstancePtr PStoreCreateInstance;
    	
    	PStoreCreateInstance = 
    		(PStoreCreateInstancePtr)GetProcAddress(hPstoreDLL, "PStoreCreateInstance");
    
    	IPStorePtr spPStore; 
    
    	HRESULT hRes;
    	
    	hRes = PStoreCreateInstance(&spPStore, 0, 0, 0);
    
    	IEnumPStoreTypesPtr spEnumTypes;
    
    	hRes = spPStore->EnumTypes(0, 0, &spEnumTypes);
    
    	GUID typeGUID;
    
    	unsigned long ul1;
    
    	for(int i = 0; i < 5; i++) // Internet Explorer Type
    		hRes = spEnumTypes->Next(1, &typeGUID, &ul1);
    
    
    	IEnumPStoreTypesPtr spEnumSubTypes;
    
    	GUID subtypeGUID;
    
    	hRes = spPStore->EnumSubtypes(0, &typeGUID, 0, &spEnumSubTypes);
    
    	hRes = spEnumSubTypes->Next(0, &subtypeGUID, &ul1); // Internet Explorer Subtype
    
    	IEnumPStoreItemsPtr spEnumItems;
    
    	hRes = spPStore->EnumItems(0, &typeGUID, &subtypeGUID, 0, &spEnumItems);
    
    	LPWSTR lpwstr;
    	
    		hRes = spEnumItems->Next(0, &lpwstr, &ul1);
    		wcout << lpwstr << endl;
    
    
    	CoUninitialize();
    }
    ... and you see what happens.

  6. #6

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2000
    Location
    Birmingham, AL
    Posts
    1,276
    PS - Anybody that knows win2K Protected Storage, feel free to jump in.

  7. #7
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Code:
    hRes = spEnumItems->Next(0, &lpwstr, &ul1);
    Shouldn't that just be "lpwstr" not "&lpwstr"?
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  8. #8

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2000
    Location
    Birmingham, AL
    Posts
    1,276
    Well, one would think it should be. The parameter is actually

    LPWSTR* rgelt

    go figure.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width