|
Hello ,
Please can anyone help with this , i have a class defined in my header file SecFishMain.h , i have included the header file in the SecFishMain.cpp file but i keep getting error 2653 and 2065
2653 - "SecFishMain is not a class/namespace"
2063 - "analysisOpt undeclared identifier" ,"userOpt undeclared identifier"
Find code below
SecFishMain.h
#ifndef SECFISHMAIN_H
#define SECFISHMAIN_H
#include <string.h>
using namespace System;
using namespace System::IO;
class SecFishMain
{
public:
SecFishMain(); //Constructor
~SecFishMain(); //Destructor
//Supporting Variables
public:
static int userOpt;
static int analysisOpt;
static unsigned long int textLength;
static unsigned long int keyLength;
};
#endif;
SecFishMain.cpp
// SecFish.cpp : main project file.
#include "StdAfx.h"
#include "SecFishMain.h"
#include "Form1.h"
#include <iostream>
#include <iterator>
#include <bitset>
#include <stdlib.h>
#include <fstream>
//Defining Static variables
int SecFishMain::userOpt;
int SecFishMain::analysisOpt;
unsigned long int SecFishMain::textLength;
unsigned long int SecFishMain::keyLength;
D
|
|
|
|
|
Hi,
I have a key, for that i need to change the permissions for admins to full control, system to full control and power usres to only have read access and all others should not have access.
i have written this code,RegSetRegisterKey API is executing correctly, but if i open the registry using regedit, and open the dialog box for permissions, it is not checking the check boxes for full control and read access.
How to make these check boxes to check for the respective permissions.
SID_IDENTIFIER_AUTHORITY securityid = SECURITY_NT_AUTHORITY;
PSID pAdministratorsSid = NULL;
PSID pSystemSid = NULL;
PSID pPowerusersSid = NULL;
SECURITY_DESCRIPTOR sd;
PACL pDacl = NULL;
DWORD dwAclSize;
HKEY hKey;
LONG lRetCode;
BOOL bSuccess = FALSE;
lRetCode = RegOpenKeyEx(
HKEY_LOCAL_MACHINE,
TEXT("SOFTWARE\\mykey"),
0,
WRITE_DAC,
&hKey
);
if(lRetCode != ERROR_SUCCESS) {
printf("RegOpenKeyEx error! (rc=%lu)\n", lRetCode);
return RTN_ERROR;
}
if(!AllocateAndInitializeSid(
&securityid,
2,
SECURITY_BUILTIN_DOMAIN_RID,
DOMAIN_ALIAS_RID_ADMINS,
0, 0, 0, 0, 0, 0,
&pAdministratorsSid
)) goto cleanup;
AllocateAndInitializeSid(
&securityid,
1,
SECURITY_LOCAL_SYSTEM_RID,
0, 0, 0, 0, 0, 0, 0,
&pSystemSid
) ;
AllocateAndInitializeSid(
&securityid,
2,
SECURITY_BUILTIN_DOMAIN_RID,
DOMAIN_ALIAS_RID_POWER_USERS,
0, 0, 0, 0, 0, 0,
&pPowerusersSid
);
dwAclSize = sizeof(ACL) +
3 * ( sizeof(ACCESS_ALLOWED_ACE) - sizeof(DWORD) ) +
GetLengthSid(pSystemSid)
+GetLengthSid(pAdministratorsSid)
+GetLengthSid(pPowerusersSid);
pDacl=(PACL)LocalAlloc(0,dwAclSize);
if(pDacl == NULL) goto cleanup;
if(!InitializeAcl(pDacl, dwAclSize, ACL_REVISION))
goto cleanup;
if(!AddAccessAllowedAce(
pDacl,
ACL_REVISION,
KEY_ALL_ACCESS,
pAdministratorsSid
)) goto cleanup;
AddAccessAllowedAce(
pDacl,
ACL_REVISION,
KEY_READ,
pPowerusersSid
) ;
AddAccessAllowedAce(
pDacl,
ACL_REVISION,
KEY_ALL_ACCESS,
pSystemSid
) ;
if(!InitializeSecurityDescriptor(&sd, SECURITY_DESCRIPTOR_REVISION))
goto cleanup;
if(!SetSecurityDescriptorDacl(&sd, TRUE, pDacl, TRUE)) {
printf("SetSecurityDescriptorDacl error! (rc=%lu)\n",
GetLastError());
goto cleanup;
}
lRetCode = RegSetKeySecurity(
hKey,
(SECURITY_INFORMATION)DACL_SECURITY_INFORMATION,
&sd
);
if(lRetCode != ERROR_SUCCESS) {
printf("fail\n);
goto cleanup;
}
else printf("Success"); //i am getting success
bSuccess = TRUE; // indicate success
cleanup:
RegCloseKey(hKey);
RegCloseKey(HKEY_LOCAL_MACHINE);
if(pDacl != NULL)
HeapFree(GetProcessHeap(), 0, pDacl);
if(pSystemSid != NULL)
FreeSid(pSystemSid);
if(pAdministratorsSid != NULL)
FreeSid(pAdministratorsSid);
if(pPowerusersSid != NULL)
FreeSid(pPowerusersSid);
|
|
|
|
|
This is the C++/CLI forum, this code is C.
Try the visual C++ forum.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
the following are the questions...can any body here can help me to get this solution...( it can be either in java or c++ )
1. Define a class Income having the interface Pay salary, Compute Deductions, Calculate Tax. Salary consists of Basic, DA, 15% of basic as HRA. Deductions are for the staff canteen and PF at 8% of Basic. Tax is 20% for annula incomes lass than one laks rupees and 30% above this. A tax surcharge of 10% is additionally charged for the latter income group.
2.Employees have a number, date of birth (dd mm yy), rank, and salary. When an employee is first recruited then all these are given values of 0. Upon confirmation, the actual values of these are entered for the employee. Employees can be given a salary raise of 10% of their previous salary. Their rank can be incremented by 1 and when this happens an employee gets an increment of 25%.
i would very much thankful if you guys can help me....
Skydeegay
|
|
|
|
|
What does "help me to get the solution mean", if not 'do my homework for me' ?
You're not even in the right forum.
I recommend trying to do your own homework, then, when you get stuck, ask some questions in the visual C++ forum, unless you want to do your code in .NET.
And, if you write it in Java, there's no Java forum here.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
thnx for ur sucking re...
|
|
|
|
|
You won't get any help here with that attitude.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
Hei sorry....i think you got so irritated....what happen is..just out of tense yesterday i wrote here this questions because today i have to show to my lab instructor and it carries 10 marks each....so with full hope to get codings for it ..i just wrote here...but now i knew that i am so foolish to think that i will get my answer from the wrong sites right ?...so i am sorry .....never mind...i know what i said to you...this is all due to out of little hopeloose... i wrote it ..i am sorry okai...
hope you will not keep it mind....dont take me in that way now onwards...sorry...
|
|
|
|
|
I used to be a tutor many years ago. Students that need help were required to bring something to the table. They had to show some effort to complete the homework assignment. Believe it or now, you learn from your failures. After the failure, you benefit from any help you receive since you can actually ask questions that pertain to the issue you are trying resolve. Right now, you are only stating the homework assignment.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
You're more than welcome. Believe it or not, telling you to do your own homework is helping you more than doing it for you.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hei sorry....i think you got so irritated....what happen is..just out of tense yesterday i wrote here this questions because today i have to show to my lab instructor and it carries 10 marks each....so with full hope to get codings for it ..i just wrote here...but now i knew that i am so foolish to think that i will get my answer from the wrong sites right ?...so i am sorry .....never mind...i know what i said to you...this is all due to out of little hopeloose... i wrote it ..i am sorry okai...
hope you will not keep it mind....dont take me in that way now onwards...sorry...
|
|
|
|
|
I know it sounds convoluted ...
I have an existing unmanaged c++ static library which uses gcroot to access some c# classes.
for example:
I have something like this
gcroot <MyCSharpClass *>
somewhere in one of the header files of the unmanaged C++ library.
I am now trying to use a C++/CLI dll which will include this header file but i get the following error:
error C3699: '*' : cannot use this indirection on type 'MyCSharpClass ' compiler replacing '*' with '^' to continue parsing
The unmanaged c++ libary is compiled with /clr:old syntax and the new c++/CLI library is compiled only with /clr. I already have put in a bit of code in the c++/CLI library using the ref class, ^, etc so i cannot (easily) change it to using /clr:old.
My question is: is it even possible to access the gcroot member declared in a unmanaged library from a c++/CLI assembly?
Notes:
1. Although i have the source code for this unmanaged c++ static library, i rather not change its source code since that opens a whole new can of worms.
2. This following info may not be relevant: To avoid a "ambiguous IServiceProvider" error, i had to manually include #include <shobjidl.h> in my stdafx.h file of my C++/CLI dll.
3. I have looked into Fraser's book but could not find any info (Nishant's book is on its way).
bipin pillai
|
|
|
|
|
Nishant's book is very good on explaining using managed and native code. However, I believe "Expert C++/CLI.Net for Visual C++ Programmers" by Marcus Heege (Apress) goes into more detail about this subject. Nevertheless, your scenario is a bit weird, and I haven't seen anything dealing with this yet. However, I haven't completed reading each book yet.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
Please can you help me...I have my code written in C++ and I want to run it in c#(because I want to make a interface in c# for my algorithm), I know that I must make an "dll" in C++, thus I can use my code in C# but I don't know how to do this "dll" in c++....thanks in advance
lavi
|
|
|
|
|
Look at the C++/CLI Articles[^] there are several examples of making a managed wrapper for native libraries.
led mike
|
|
|
|
|
sorry I didn't worked with something like this and my time is short...can you tell me if this code is good for creating an "dll",I know that it create shell32.dll but, is this good for creating me a dll in c++ for my algorithm so I can run it in c#
/ / dllsharp.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#using <mscorlib.dll>
using namespace System;
using namespace System::Runtime::InteropServices;
// Declare the function that is exported from unmanaged dll (shell32.dll).
[DllImport("shell32.dll")]
extern "C" int _cdecl ShellExecute(int hwnd, // Handle to a parent window.
String *strVerb, // Action to be performed.
String *strFileName, // File or object on which to execute the specified verb.
String *strParameters, // Parameters to be passed to the application.
String *strDirectory, // Default directory.
int nShowCmd); // Flags.
// Managed class demonstrates Runtime's Platform Invocation Service
// (P/Invoke) to call unmanaged code from managed code.
__gc class Launcher
{
public:
// Starts program that specified by strFileName parameter
static int StartProgram(String *strFileName)
{
return ShellExecute(0,
S"Open",
strFileName,
String::Empty,
String::Empty,
1 /*SW_SHOWNORMAL*/);
}
};
// This is the entry point for this application
int main( int argc, char *argv[ ])
{
// Check parameters.
if(argc < 2)
{
Console::Write(S"Not enough parameters.");
return 0;
}
// Call static function of the Launcher class and start program.
if(Launcher::StartProgram(new String(argv[1])) < 33)
Console::Write(S"Couldn't launch the program!");
return 0;
}
|
|
|
|
|
my time is short man!
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
k...forget about that...can you answer me to this question please...if I run the code above wy it give me this error:
Error 1 fatal error C1190: managed targeted code requires a '/clr' option
|
|
|
|
|
You need to enable CLR in your compiler options.
In VS2003 .NET it's at Project Properties->General->Use Managed Extensions
In VS2005 it's at Project Properties->Configuration Properties->General->Common Language Runtime Support
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Mark Salsbery wrote: my time is short man!
Yes the famous Short Stack Software Development Process introduced by the well known Technology Expurts from The International House of Pancakes.
led mike
|
|
|
|
|
led mike wrote: Yes the famous Short Stack Software Development Process introduced by the well known Technology Expurts from The International House of Pancakes.
My time is short too! Tell the short order cook at IHOP that I'll take a stack. No, make it a queue.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
Hello,
I am trying to get current login user name using my own windows service program using VC++.Net 2005, windows XP. The code used to develop windows service contains only unmanaged one. But in order to retrieve the current login name.. i am using the help of System::Management class, for which i included necessary namespaces in its .cpp file.
actually i am trying interpret the following statement of c# into c++:
System::Management::Collections mc;
foreach(System::Management::Object mo in mc){..do this..}
my approach was somewhat like this in the following way:
CString CUSBActivity::Get_User_Name()
{
CString Username=_T("");
System::Management::ManagementObjectSearcher^ q = nullptr;
System::Management::ManagementObjectCollection^ mc = nullptr;
System::Management::ManagementObject^ mo = nullptr;
System::Collections::IEnumerator^ enu = nullptr;
q = gcnew System::Management::ManagementObjectSearcher("Select * from Win32_Process");
mc = q->Get();
enu = mc->GetEnumerator();
mo = (System::Management::ManagementObject^)enu->Current;
while(enu->MoveNext())
{
DebugBreak();
mo = (System::Management::ManagementObject ^)enu->GetType();
Username = mo["username"]->ToString();
mc->GetEnumerator()->MoveNext();
}
return Username;
}
But when i run this, i am getting the run time exception and the Username is null.
Could anybody... assist me in fixing this thank u.
Anee
|
|
|
|
|
In your while loop you do this:
mo = (System::Management::ManagementObject ^)enu->GetType();
That doesn't look like a valid cast to me.
Did you mean
mo = (System::Management::ManagementObject ^)enu->Current;
??
What line is the exception occurring on?
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Hi all
Is it a good idea to write cryptography and steganography application in C++.NET
Well i guess .NET already includes the classes for cryptography but i dont think it would be of any good for me as i have to create my final yr project and i dont think its a good idea to use already created classes. So can i create my own classes. Is there any reference over the net for this task .
Or is it better to use C++(BORLAND). Well basically i dont like borland. I want to use C++.NET OR C#.NET and i dont understand VC++ so i cant use that.
So any suggestion would be greatly appreciated.
Thanks
|
|
|
|
|
Software_Specialist wrote: I want to use C++.NET OR C#.NET and i dont understand VC++ so i cant use that.
I'm not sure what you mean here.
I'd just use straight C++, using VS2005. If you're not doing any GUI, then the express edition will work just fine.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|