Hi, I have this C++ function:
Save in a file called vista.cpp
Then in Bmax I go:
But when I compile, I get a page full of errors like this:
I've NO idea where to start. I must be doing something really basic wrong. Any ideas? Thanks.
Oh an dI tried saving the file as .c and importing that but got similar errors.
bool CreateDirectoryUserFullAccess(LPCTSTR lpPath) { int f = CreateDirectory(lpPath,NULL); if(!f) return false; HANDLE hDir = CreateFile(lpPath,READ_CONTROL|WRITE_DAC,0,NULL,OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS,NULL); if(hDir == INVALID_HANDLE_VALUE) return true; ACL* pOldDACL=NULL; SECURITY_DESCRIPTOR* pSD = NULL; GetSecurityInfo(hDir,SE_FILE_OBJECT,DACL_SECURITY_INFORMATION,NULL,NULL,&pOldDACL,NULL,(void**)&pSD); EXPLICIT_ACCESS ea={0}; ea.grfAccessMode = GRANT_ACCESS; ea.grfAccessPermissions = GENERIC_ALL; ea.grfInheritance = CONTAINER_INHERIT_ACE|OBJECT_INHERIT_ACE; ea.Trustee.TrusteeType = TRUSTEE_IS_GROUP; ea.Trustee.TrusteeForm = TRUSTEE_IS_NAME; ea.Trustee.ptstrName = TEXT("Users"); ACL* pNewDACL = NULL; SetEntriesInAcl(1,&ea,pOldDACL,&pNewDACL); SetSecurityInfo(hDir,SE_FILE_OBJECT,DACL_SECURITY_INFORMATION,NULL,NULL,pNewDACL,NULL); LocalFree(pSD); LocalFree(pNewDACL); CloseHandle(hDir); return true; }
Save in a file called vista.cpp
Then in Bmax I go:
Strict Import "vista.cpp"
But when I compile, I get a page full of errors like this:
Compiling:vista.cpp C:/BlitzMax/Jake/demo/vista.cpp:1: `LPCTSTR' was not declared in this scope C:/BlitzMax/Jake/demo/vista.cpp:1: parse error before `)' token C:/BlitzMax/Jake/demo/vista.cpp: In function `bool CreateDirectoryUserFullAccess(...)': C:/BlitzMax/Jake/demo/vista.cpp:3: `lpPath' undeclared (first use this function) C:/BlitzMax/Jake/demo/vista.cpp:3: (Each undeclared identifier is reported only once for each function it appears in.) C:/BlitzMax/Jake/demo/vista.cpp:3: `NULL' undeclared (first use this function) C:/BlitzMax/Jake/demo/vista.cpp:3: `CreateDirectory' undeclared (first use this function) C:/BlitzMax/Jake/demo/vista.cpp:7: `HANDLE' undeclared (first use this function) C:/BlitzMax/Jake/demo/vista.cpp:7: parse error before `=' token C:/BlitzMax/Jake/demo/vista.cpp:8: `hDir' undeclared (first use this function) C:/BlitzMax/Jake/demo/vista.cpp:8: `INVALID_HANDLE_VALUE' undeclared (first use this function) C:/BlitzMax/Jake/demo/vista.cpp:11: `ACL' undeclared (first use this function) C:/BlitzMax/Jake/demo/vista.cpp:11: `pOldDACL' undeclared (first use this function) C:/BlitzMax/Jake/demo/vista.cpp:12: `SECURITY_DESCRIPTOR' undeclared (first use this function) C:/BlitzMax/Jake/demo/vista.cpp:12: `pSD' undeclared (first use this function) C:/BlitzMax/Jake/demo/vista.cpp:13: `SE_FILE_OBJECT' undeclared (first use this function) C:/BlitzMax/Jake/demo/vista.cpp:13: `DACL_SECURITY_INFORMATION' undeclared (first use this function) C:/BlitzMax/Jake/demo/vista.cpp:13: `GetSecurityInfo' undeclared (first use this function) C:/BlitzMax/Jake/demo/vista.cpp:15: `EXPLICIT_ACCESS' undeclared (first use this function) C:/BlitzMax/Jake/demo/vista.cpp:15: parse error before `=' token C:/BlitzMax/Jake/demo/vista.cpp: At global scope: C:/BlitzMax/Jake/demo/vista.cpp:16: syntax error before `.' token C:/BlitzMax/Jake/demo/vista.cpp:17: syntax error before `.' token C:/BlitzMax/Jake/demo/vista.cpp:18: syntax error before `.' token C:/BlitzMax/Jake/demo/vista.cpp:19: syntax error before `.' token C:/BlitzMax/Jake/demo/vista.cpp:20: syntax error before `.' token C:/BlitzMax/Jake/demo/vista.cpp:21: syntax error before `.' token C:/BlitzMax/Jake/demo/vista.cpp:23: syntax error before `*' token C:/BlitzMax/Jake/demo/vista.cpp:24: `ea' was not declared in this scope C:/BlitzMax/Jake/demo/vista.cpp:24: `pNewDACL' was not declared in this scope C:/BlitzMax/Jake/demo/vista.cpp:24: ISO C++ forbids declaration of ` SetEntriesInAcl' with no type C:/BlitzMax/Jake/demo/vista.cpp:24: initializer list being treated as compound expression C:/BlitzMax/Jake/demo/vista.cpp:26: `pNewDACL' was not declared in this scope C:/BlitzMax/Jake/demo/vista.cpp:26: ISO C++ forbids declaration of ` SetSecurityInfo' with no type C:/BlitzMax/Jake/demo/vista.cpp:26: initializer list being treated as compound expression C:/BlitzMax/Jake/demo/vista.cpp:28: ISO C++ forbids declaration of `LocalFree' with no type C:/BlitzMax/Jake/demo/vista.cpp:29: `pNewDACL' was not declared in this scope C:/BlitzMax/Jake/demo/vista.cpp:29: ISO C++ forbids declaration of `LocalFree' with no type C:/BlitzMax/Jake/demo/vista.cpp:29: redefinition of `int LocalFree' C:/BlitzMax/Jake/demo/vista.cpp:28: `int LocalFree' previously defined here C:/BlitzMax/Jake/demo/vista.cpp:30: ISO C++ forbids declaration of `CloseHandle ' with no type C:/BlitzMax/Jake/demo/vista.cpp:31: parse error before `return' Build Error: failed to compile C:/BlitzMax/Jake/demo/vista.cpp
I've NO idea where to start. I must be doing something really basic wrong. Any ideas? Thanks.
Oh an dI tried saving the file as .c and importing that but got similar errors.