|
|
main()
{
CStringArray lDirectory;
lDirectory.Add("designer.temp.directory");
lDirectory.Add("designer.mediator.xml");
GetDirectoryPermission(lDirectory);
}
bool GetDirectoryPermission(CStringArray lDirectory)
{
.....
}
it gives me an error
"error C2664: cannot convert parameter 1 from 'CStringArray' to 'CStringArray'"
|
|
|
|
|
When passing a parameter "by value" (in your case the CStringArray object), the whole thing is to be passed, but there is no copy constructor available. That's why you get the error.
Therefore, you should pass the parametter by reference:
bool GetDirectoryPermission(CStringArray& lDirectory)
SkyWalker
|
|
|
|
|
Thanks for u r reply.
I am getting some linker error too. I think some library Files are missing which one i should include ?
msxml6Exp error LNK2019: unresolved external symbol __beginthreadex referenced in function "public: int __thiscall CWinThread::CreateThread(unsigned long,unsigned int,struct _SECURITY_ATTRIBUTES *)" (?CreateThread@CWinThread@@QAEHKIPAU_SECURITY_ATTRIBUTES@@@Z)
msxml6Exp error LNK2019: unresolved external symbol __endthreadex referenced in function "void __stdcall AfxEndThread(unsigned int,int)" (?AfxEndThread@@YGXIH@Z)
msxml6Exp error LNK2005: "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z) already defined in libcpd.lib(newop.obj)
|
|
|
|
|
You are missing something there, that's for sure
If you are using the project wizard, use MFC SDI Application Project, rather then win32.
Another idea would be that your project should be "multithreaded".
SkyWalker
|
|
|
|
|
am i missing some Library or header ? My application is not multithreaded. I am not using wizard to make one. initially it was Win32 console application. But to use msxml and all other stuff like CString class its now MFC.
-- modified at 10:49 Monday 28th August, 2006
update :: i think i have figured out whats wrong..i have made many mistakes since i m not familier with .net/microsoft platform..
Thanks for u r help
|
|
|
|
|
See here[^] and here[^] maybe it is some helpful to you
|
|
|
|
|
If he was passing it by value before, he most likely wants it to be passed by const-reference:
bool GetDirectoryPermission(const CStringArray& lDirectory)
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
|
code4jigar wrote: passing CStringArray as paramenter
never pass CString Arrat by value, there can be performance issue, better go for const refernce when you don't want to modified it at function level
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
What performance issues do i face ?
|
|
|
|
|
code4jigar wrote:
What performance issues do i face ?
whole of the CString Get copied into new variable when you pass by value!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Hi Guys,
Can anyone plz suggest some links for CTabctrl + Property Page application( eg: the page which is displayed when Properties of a folder or file is clicked.
Thanks in Advance
Velayudhan
|
|
|
|
|
|
See here[^] maybe it is some helpful to you
|
|
|
|
|
Is there any API to convert C:\DOCUME~1\SUNIT~1.SIN\LOCALS~1\Temp to C:\Documents and Settings\sunit.sinha\Local Settings\Temp.
Pls help me.
hanx in advance
never say die
|
|
|
|
|
sunit5 wrote: Re: convert File Path form DOS to Windows type
GetLongPathName()
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Thanx a lot
never say die
|
|
|
|
|
sunit5 wrote: C:\Documents and Settings\sunit.sinha\Local Settings\Temp.
GetShortPathName to convert it back!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Hi,
in my applcation,i have graphs, trend graph like that.Each view i have this kind of diagrams..I have to print this page when i press print button in my view page.How can i do that?Till now i didnot work in printers.
Is there tutorial?Pls help me?
Anu
|
|
|
|
|
Hi,
Please use this code.
CPrintDialog printdlg( FALSE );
printdlg.DoModal();
Regards
Velayudhan
|
|
|
|
|
See PrintDlg(...)StartDoc(...)StartPage(...)
|
|
|
|
|
Hi!
I am having problem using CopyFile() function call. I am trying To copy a file which is not a read only file to a new folder created using CreateDirectory(). But Its giving me error numbered 5 saying Access Denied.
I found that whenever I create new directory It is read only by default. I cant change/remove its read only attributes.I am using XP SP2 and I am having administrative rights.
How should I do this? How can I copy file to a readonly folder?
Thx
|
|
|
|
|
sach!! wrote: How can I copy file to a readonly folder?
Did this in a console based application.
#include "windows.h"
DWORD CreateDirWithSecurity(LPCTSTR lpPath)
{
SECURITY_ATTRIBUTES mySecAttrib;
SECURITY_DESCRIPTOR mySecDesc;
PACL pAcl = NULL;
DWORD cbAcl = 0,dwNeeded = 0,dwError = 0;
HANDLE hToken;
PTOKEN_USER ptu = NULL;
if(!OpenProcessToken( GetCurrentProcess(), TOKEN_QUERY, &hToken))
return GetLastError();
GetTokenInformation( hToken, TokenUser, NULL, 0, &dwNeeded);
if(GetLastError() != ERROR_INSUFFICIENT_BUFFER)
{
dwError = GetLastError();
goto clearAll;
}
ptu = (TOKEN_USER*)malloc(dwNeeded);
if (!GetTokenInformation(hToken, TokenUser, ptu, dwNeeded, &dwNeeded))
{
dwError = GetLastError();
goto clearAll;
}
cbAcl = sizeof(ACL) + ((sizeof(ACCESS_ALLOWED_ACE) - sizeof(DWORD)) + GetLengthSid(ptu->User.Sid));
pAcl = (ACL*) malloc (cbAcl);
if(!InitializeAcl(pAcl, cbAcl, ACL_REVISION))
{
dwError = GetLastError();
goto clearAll;
}
if(!AddAccessAllowedAce(pAcl,ACL_REVISION,GENERIC_ALL|STANDARD_RIGHTS_ALL|SPECIFIC_RIGHTS_ALL,ptu->User.Sid))
{
dwError = GetLastError();
goto clearAll;
}
InitializeSecurityDescriptor(&mySecDesc,SECURITY_DESCRIPTOR_REVISION);
SetSecurityDescriptorDacl(&mySecDesc,TRUE,pAcl,FALSE);
SetSecurityDescriptorOwner(&mySecDesc,ptu->User.Sid,FALSE);
SetSecurityDescriptorGroup(&mySecDesc,NULL,FALSE);
SetSecurityDescriptorSacl(&mySecDesc, FALSE,NULL,FALSE);
mySecAttrib.nLength = sizeof(SECURITY_ATTRIBUTES);
mySecAttrib.lpSecurityDescriptor = &mySecDesc;
mySecAttrib.bInheritHandle = TRUE;
CreateDirectory(lpPath, &mySecAttrib);
dwError = GetLastError();
clearAll:
if(ptu) free(ptu);
if(pAcl) free(pAcl);
CloseHandle(hToken);
return dwError;
}
int _tmain(int argc, _TCHAR* argv[])
{
CreateDirWithSecurity ("C:\\TestDir");
FILE *fp;
fp=fopen ("C:\\TestDir\\TestMe.txt","a+");
fclose (fp);
CopyFile ("C:\\TestDir\\TestMe.txt","C:\\TestDir\\TestMe1.txt",true);
return 0;
}
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
I have a GUI which uses some of the Registry access functions. What they do is basically read some contents from the windows registry which will be used in the GUI. The problem i face is that, if USER is logged into the machine as ADMIN and then uses the GUI, the GUI is able to read registry contents. But if the USER is logged into machine as restricted USER without ADMIN privilages, then the GUI is not able to read registry contents. I was trying the GUI in DEBUG mode and found that, in restricted USER mode the registry functions are returning a error value (5 or 6). But in ADMIN mode it returns "0" which is the success return value.
Any idea why this problem occurring and any soutions?
Thanks in advance.
|
|
|
|