1

I wrote an app in C++, and downloaded some samples code from the internet (like this and this), but when I try to compile the code I get compilation errors like:

error C2664: 'CertNameToStrW' : cannot convert parameter 4 from 'CHAR [1000]' to 'LPWSTR'

error C2664: 'send' : cannot convert parameter 2 from 'BYTE [200]' to 'const char *'

and so on.

Certainly, I can solve it by explicit conversion like suggested in this question. but I want to ask if this behavior is reasonable? I assume that Microsoft guys compile their code before they upload it to MSDN. What do I miss? Maybe I have to install somthing? can anyone please help?

Community
  • 1
  • 1
RRR
  • 3,937
  • 13
  • 51
  • 75

2 Answers2

1

It's caused by having the wrong character set, see here:

http://www.ucancode.net/faq/Visual_c_character_sets-Unicode-MBCS.htm

Stuart Golodetz
  • 20,238
  • 4
  • 51
  • 80
0

You need to turn off Unicode from your project settings Project Properties -> General -> Project Defaults -> Character Set or use win32 api functions with A postfix like CertNameToStrA instead of CertNameToStr.

Emir Akaydın
  • 5,708
  • 1
  • 29
  • 57