Link to home
Start Free TrialLog in
Avatar of JimmyJJ
JimmyJJ

asked on

How do I compile this?

Hi,

I'm new to C++ but not new to programming.
I need to compile the following code at:

http://msdn.microsoft.com/library/en-us/seccrypto/security/example_c_program_using_cryptprotectdata.asp?frame=true

I have Visual Studio 2005 with C++. Could anyone please tell me how to compile the code in the site above?
When I try to compile I get errors.

The code above is just an example.
If you are able to get me a code with a working CryptProtectData function (see: http://msdn.microsoft.com/library/en-us/seccrypto/security/cryptprotectdata.asp) - Then that will do too, since that is what I need.

Thank you in advance,
Avatar of smidgie82
smidgie82
Flag of United States of America image

Hi JimmyJJ,
Can you post a copy of the compile-time errors you get?  That'll help out quite a bit.  It's likely not the code that's the problem, but rather the build environment.

Avatar of AlexFM
AlexFM

I created C++ Win32 Console application in VC++ 2005 and pasted this code to it. I got only two errors:
Function exit is not defined - I added stdlib.h include
Unresolved external symbols - I added Crypt32.lib to the list of Linker dependencies.

Program is build correctly.
Avatar of JimmyJJ

ASKER

Hi,

Ok well Im new to C++, so I simply open a new project in Visual Studio, then in the main cpp file I paste the complete source.

First error I get is: "fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' to your source?"

So I add the line "#include <stdafx.h>" to the source. Then it gives many errors:

Error      1      error C2065: 'DATA_BLOB' : undeclared identifier            18
Error      2      error C2146: syntax error : missing ';' before identifier 'DataIn'            18
Error      3      error C2065: 'DataIn' : undeclared identifier            18
Error      4      error C2146: syntax error : missing ';' before identifier 'DataOut'            19
Error      5      error C2065: 'DataOut' : undeclared identifier            19
Error      6      error C2146: syntax error : missing ';' before identifier 'DataVerify'            20
Error      7      error C2065: 'DataVerify' : undeclared identifier            20
Error      8      error C2065: 'BYTE' : undeclared identifier            21
Error      9      error C2065: 'pbDataInput' : undeclared identifier            21
Error      10      error C2059: syntax error : ')'            21
Error      11      error C2065: 'DWORD' : undeclared identifier            22
Error      12      error C2146: syntax error : missing ';' before identifier 'cbDataInput'            22
Error      13      error C2065: 'cbDataInput' : undeclared identifier            22
Error      14      error C3861: 'strlen': identifier not found            22
Error      15      error C2228: left of '.pbData' must have class/struct/union            23
Error      16      error C2228: left of '.cbData' must have class/struct/union            24
Error      17      error C2065: 'CRYPTPROTECT_PROMPTSTRUCT' : undeclared identifier            25
Error      18      error C2146: syntax error : missing ';' before identifier 'PromptStruct'            25
Error      19      error C2065: 'PromptStruct' : undeclared identifier            25
Error      20      error C2065: 'LPWSTR' : undeclared identifier            26
Error      21      error C2146: syntax error : missing ';' before identifier 'pDescrOut'            26
Error      22      error C2065: 'pDescrOut' : undeclared identifier            26
Error      23      error C2070: ''unknown-type'': illegal sizeof operand            36
Error      24      error C3861: 'ZeroMemory': identifier not found            36
Error      25      error C2228: left of '.cbSize' must have class/struct/union            37
Error      26      error C2070: ''unknown-type'': illegal sizeof operand            37
Error      27      error C2228: left of '.dwPromptFlags' must have class/struct/union            38
Error      28      error C2065: 'CRYPTPROTECT_PROMPT_ON_PROTECT' : undeclared identifier            38
Error      29      error C2228: left of '.szPrompt' must have class/struct/union            39
Error      30      error C3861: 'CryptProtectData': identifier not found            44
Error      31      error C3861: 'CryptUnprotectData': identifier not found            63
Error      32      error C2228: left of '.pbData' must have class/struct/union            72
Error      33      error C3861: 'LocalFree': identifier not found            87
Error      34      error C2228: left of '.pbData' must have class/struct/union            88
Error      35      error C3861: 'LocalFree': identifier not found            88
Error      36      error C2228: left of '.pbData' must have class/struct/union            89
Error      37      error C3861: 'LocalFree': identifier not found            89
Error      38      error C3861: 'GetLastError': identifier not found            103
Error      39      error C3861: 'exit': identifier not found            105
ASKER CERTIFIED SOLUTION
Avatar of AlexFM
AlexFM

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of JimmyJJ

ASKER

Thank you very much.
Avatar of JimmyJJ

ASKER

I have one more question,

where do I now find the compiled .exe file?
Avatar of JimmyJJ

ASKER

Nevermind ;-)