I'm currently developing a program that reads strings from a text file in 8-bit ASCII mode, and I make a function to assign that string into a wchar\_t\*

Here I'm using atlconv.h and USES\_CONVERSION macro to convert the string into wstring. So here is the code:

```
void CSampleProvider::getCopy(CREDENTIAL_PROVIDER_FIELD_DESCRIPTOR *a, const string s) {
    USES_CONVERSION;
    wstring temp(A2W (s.c_str ()));
    a->pszLabel = new WCHAR(temp.length()+1);
    if (!a->pszLabel)
        return;
    wcscpy_s(a->pszLabel, temp.size()+1, (LPWSTR)temp.c_str());
    ::MessageBox(NULL,s.c_str(),"getCopy",0);
    return;
}

```

I used a debugger to watch line by line. It works well (i.e. the content of a->pszLabel is as I expected, the same as the content of s) until it reaches return. As it returned, an error popped up: 

```
First-chance exception at 0x770f3067 in CPTest.exe: 0xC0000005: Access violation reading location 0x00200074.
Unhandled exception at 0x770f3067 in CPTest.exe: 0xC0000005: Access violation reading location 0x00200074.

```

Does anyone know how to fix this? Please tell me. Your answers are highly appreciated :) 

Thanks,
Reinardus

EDIT: Oh yeah, the type CREDENTIAL\_PROVIDER\_FIELD\_DESCRIPTOR is a struct, and one of its member is pszLabel, which is a wchar\_t\*