|
|
Hi,
I am new to vc++.
I am trying to creat file using the following code.but it is not creating the file.INVALID_HANDLE_VALUE is returned. what may be the reason for the failure.
hFile = CreateFile(m_storagePath,GENERIC_REA|ENERIC_WRITE, FILE_SHARE_READ, NULL,OPEN_ALWAYS,FILE_ATTRIBUTE_NORMAL,0);
if (hFile == INVALID_HANDLE_VALUE)
{
AfxMessageBox( "File cant be created ");
//return 0;
}
Help Ever Hurt Never
|
|
|
|
|
Call GetLastError() to get the error code, when CreateFile() returns INVALID_HANDLE_VALUE.
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
thanks for your reply.
i tried by including
DWORD dw = GetLastError();
after creating the file . and its returning 0X0000.
and dont know what the return value indicates?
please guide me.
Help Ever Hurt Never
|
|
|
|
|
Shouldn't happen. Does your code look something like this?
if (hFile == INVALID_HANDLE_VALUE)
{
DWORD dw = GetLastError();
AfxMessageBox( "File cant be created ");
}
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
|
Could be a lot of things. What is in m_ storagePath ? Does the file exist? Do you have read and write access to it? Does some other process have it open and it's only shared for reading?
|
|
|
|
|
you can get the error string by using FormatMessage() . Just change the code to as shown below. This will display the error string corresponding to that of error code.
hFile = CreateFile( m_storagePath,<br />
GENERIC_READ|GENERIC_WRITE, <br />
FILE_SHARE_READ,<br />
NULL,<br />
OPEN_ALWAYS,<br />
FILE_ATTRIBUTE_NORMAL,<br />
0);<br />
<br />
<br />
if (hFile == INVALID_HANDLE_VALUE) <br />
{ <br />
LPVOID lpMsgBuf;<br />
FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | <br />
FORMAT_MESSAGE_FROM_SYSTEM | <br />
FORMAT_MESSAGE_IGNORE_INSERTS,<br />
NULL,<br />
GetLastError(),<br />
MAKELANGID( LANG_NEUTRAL, SUBLANG_DEFAULT ), <br />
( LPTSTR ) &lpMsgBuf,<br />
0,<br />
NULL );<br />
<br />
cout << endl << (LPCTSTR)lpMsgBuf << endl;<br />
<br />
LocalFree( lpMsgBuf );<br />
}
Regards,
Vijay.
God may not give us what we 'want', but he surely gives us what we 'need'.
|
|
|
|
|
How can we change the size of the splitter bar in a splitter window?
- NS -
|
|
|
|
|
Derive a custom class from CSplitterWnd class. In the constructor of derived class change the value of m_cxSplitter and m_cySplitter. Simply doing this will slove your problem and use the derived class instance
Do your Duty and Don't expect the Result
|
|
|
|
|
Thanks a lot...
I found some other useful variables too...
- NS -
|
|
|
|
|
NS17 wrote: I found some other useful variables too
Just curious...
|
|
|
|
|
I use these (where splitterwidth is the size of the splitter I want and borderwidth is the size
of the 3-D border around the views:
m_cxSplitter = m_cySplitter = splitterwidth + borderwidth * 2;
m_cxBorderShare = m_cyBorderShare = 0
m_cxSplitterGap = m_cySplitterGap = splitterwidth + borderwidth * 2;
m_cxBorder = m_cyBorder = borderwidth;
I also added customizable colors to all individual borders and the splitter which required a
CSplitterWnd::OnDrawSplitter() override.
I almost wrote an article for it (it all started in response to a CP question) but I noticed
hundreds of articles were already there LOL.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
sir,
I am working on vc++ project and it is based on document view architecture and I am trying to embed an active-x component into my project.
why it takes more time, when i try to create a component on the display document for the first time. The same component when i try to create subsequent time it takes less time. could you please throw some light on it.
Thanks & Regards,
Praveen A.
praveena@navayuga.co.in
pv_pravin@yahoo.co.in
|
|
|
|
|
To hide a dos windwow,
I placed the following line in the top of progam under all include files and the dos window will not be appeared when run the program.
#pragma comment(linker, "/subsystem:\"windows\" /entry:\"mainCRTStartup\"")
But,
I take the exe and add it to the setup file(build in .net) the dos window will appear.what a pbm.how to hide the dos window.
|
|
|
|
|
I can help u regarding this. But make u'r doubt more specific.
Come online at:-
jubinc@skype
|
|
|
|
|
Hello ,
Can anyone help with the declaration of arrays on the .NET 2.0 platform ? I get an error "subscript requires array or pointer type . Codes listed below
public: System::Void convertStringToBinary(String ^myString)
{
binaryVal = "";
__wchar_t characterArray gcnew[];
characterArray = new __wchar_t gcnew[myString->Length];
myString->CopyTo(0, characterArray, 0, myString->Length);
for(unsigned long int i=0; i<characterarray->Length; i++)
{
binaryVal = String::Concat(binaryVal, characterArray[i]>=128 ? "1":"0");
characterArray[i] %= 128;
D
|
|
|
|
|
|
Maybe something like:
array<__wchar_t> ^characterArray = gcnew array<__wchar_t>(myString->Length);
And yes, this should be posted on the C++/CLI board
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Thanks it worked
|
|
|
|
|
I need to create a quick/easy RSS Reader. Can anyone help me with the code/ or where to get it?
|
|
|
|
|
Here[^] is an example of course its C++/CLI
|
|
|
|
|
Hi,
I am using LogOnUser() API to check whether My application has similliar logon username and password same as my windows username and password. If i give a wrong user name and password it takes almost 15 secs to return. Is there a way i could make it faster?
BOOL bRes = LogonUser( m_strUser,
NULL /*domain*/,
m_strPassword,
LOGON32_LOGON_NETWORK /*dwLogonType*/,
LOGON32_PROVIDER_DEFAULT /*dwLogonProvider*/,
&hUserHandle);
It is because of passing NULL for the domain name, there are around 10 domains and that is the reason it takes so much of time i guess. Is there a way to get the current doamin pls suggest how to go about?
-- modified at 16:31 Monday 23rd April, 2007
|
|
|
|
|
AnilUnni wrote: Is there a way to get the current doamin
Use NetWkstaUserGetInfo(NULL, 1, ...) .
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi all.
I wont add to my project .dll file.
can help?
|
|
|
|