|
The reason I suggested this is that you're loading the MFC dll manually instead of compile-time linking.
It's possible that might make a difference.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
All this turns out to be because I deleted my "theApp" member - foolishly thinking that since I didn't use it, I didn't need it!
|
|
|
|
|
Hi Deleopers,
I am trying to create a directory if it's not exist, but failed to do that. Here is the code.
if( !PathFileExists(strDestFilePath) )
{
if( !PathFileExists(strDestFolder) )
{
DWORD dLastError = CreateDirectory( strDestFolder, NULL);
}
}
dest folder contains: C:\MyFolder\Data
last error code i got is 0.
Can anyone tell me the reason.
Tnaks in Advance.
Amrit Agrawal
Software Developer, Mumbai.
|
|
|
|
|
Based on the CreateDirectory[^] documentation I do not think your
DWORD dLastError = CreateDirectory( strDestFolder, NULL); statement is correct. The function returns a BOOL and not an error number.
I would replace the statement with the following code:
if( !CreateDirectory( strDestFolder, NULL ) )
{
DWORD dLastError = GetLastError();
}
The GetLastError[^] result should tell you why the folder creation failed.
0100000101101110011001000111001011101001
|
|
|
|
|
If the return value from CreateDirectory() is zero then the function failed, and you should follow this with a call to GetLastError() [^] to find the reason why.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
The CreateDirectory() function only creates the last directory in the path; if its parent doesn't exist yet it will fail.
In your example, MyFolder has to exist or it won't work.
Could this be the problem?
modified 13-Sep-18 21:01pm.
|
|
|
|
|
Good Point. CreateDirectory() != CreateTotalPath()
|
|
|
|
|
As others have mentioned, the error is probably because both MyFolder and Data have to be created at the same time and CreateDirectory is unable to do this. However, you can use SHCreateDirectory , which is capable of creating the entire specified path.
Another problem could be that you're trying to create the folder in the C drive and your program may need elevated privileges to do this.
|
|
|
|
|
Hello! I'm trying to make a MFC application that connect to a web page with a php form to upload a file.
I was thinking on simulate a POST to upload the file but i don't know how can I do this.
Anyone know how?
Thanks.
|
|
|
|
|
A sequence of calls to the WinINet APIs can simulate a POST operation. Use:
1) InternetOpen() to begin communication
2) InternetConnect() to connect to the web site
3) HttpOpenRequest() to do a POST to the script
4) HttpSendRequest() to send the data being "posted"
5) InternetReadFile() to receive any optional output the script produces (status)
6) InternetCloseHandle() to close the various handles opened by the previous steps.
You can look all these up on MSDN. Get this to work and you've learned a lot of useful stuff.
|
|
|
|
|
I have this VARIANT, called varTemp. At the end of the function, when cleanup occurs, I cant't get rid of the first value in it. I can clear the second value, which is Dispatch = 0x017a8618, and any value past 1
So when va.pa[j++] = varTemp, in debug it's SafeArray of Variant = [1] Dispatch = 0x17a8458
When the memory clears at the end of the function, the in the comutil.h in the code below
inline _variant_t::~_variant_t() throw()
::VariantClear(this);
this = safearray = 0x001afb50 safearray of VARIANT = [1](DISPATCH = 0x017a8458)
just bombs, 0xC000005: Access violation reading location 0x017a8458.
I can't figure out what is locking the memory, or there is something I did not unlock or release that is pointing to that address.
for (i = lSLBound, j = 0; i <= lSUBound; ++i) {
VARIANT varTemp;
VariantInit(&varTemp);
hr = SafeArrayGetElement(V_ARRAY(&var), &i, &varTemp);
RETURN_ON_FAILURE(hr);
if (VT_DISPATCH != V_VT(&varTemp))
return E_ADS_CANT_CONVERT_DATATYPE;
hr = V_DISPATCH(&varTemp)->QueryInterface(__uuidof(::IISMimeType),(void**) &pADMTs);
RETURN_ON_FAILURE(hr);
pADMTs->get_Extension(&bstrMimeExtension);
pADMTs->get_MimeType(&bstrMimeType);
printf("%ls -> %ls/n", (LPCWSTR) bstrMimeExtension, (LPCWSTR) bstrMimeType);
if (wcsncmp(bstrMimeExtension, pwszAddExtension, bstrMimeExtension.Length() == 0)) {
--cVariants;
}
else {
va.pa[j++] = varTemp; <-Dispatch=0x17a8458
}
VariantClear(&varTemp);
|
|
|
|
|
Hello,
I tried to put a programme into the main one as a function, but it didn´t work. Is there a way to "call" another program from the main one? Please don´t use much technical language, as I´m only beginning. All help would be much appreciated.
|
|
|
|
|
I suggest you look here[^].
|
|
|
|
|
I think you want to launch another program in your application.
::ShellExecute(NULL,_T("open"),_T("notepad.exe"),NULL,NULL,SW_SHOWNORMAL);
It will launch notepad.exe.
Regards
|
|
|
|
|
Hi Pranit,
Thanks for the info. Do I need a special header for ::ShellExecute, type include<xxxxx> for devc++?
|
|
|
|
|
Follow the link provided by Luc. Since you are only beginning, this will serve you well. The documentation he points to contains everything you need to know about including it, the "prerequesite calls" and the header file that must be included. MSDN documentation follows that standard for all the calls so you can determine that for anything. No need to ask and sit and wait for someone to answer, it's all in your hands.
|
|
|
|
|
|
Hi Pranit,
Thanks a lot. I thence dowloaded the latest version and installed it.
|
|
|
|
|
The first two replies suggest "ShellExecute". However, that's "launch", not "call" as a function. If you want a "return value" or other "results" of the program[me] then you will need a more technical discussion on what you want.
CreateProcess()[^]
allows you to monitor the completion, get the completion status (which could mean anything to your application, like a result) or do other ways of getting more complex results.
Good luck.
|
|
|
|
|
Hi Chuck,
Your reply seems just what I need. Sorry about the lack of information, it´s just lack of experience on my part. What I´m trying to do is to read an entering car´s number plate, which is done by ANPR camera and software (bought) which includes OCR,get the number plate from this program, then compare it with about 400 registered cars. If a match is found, another program sets one of the pins of the parallel port, so I´ve got to execute my 3 programs sequentially to achieve the desired result. The main program fills in a database with number plate, address and owner name, with editing facility. My second program gets the entering number plate and checks it against the forementioned list, and the third program lets the car in by opening the gate if the compare is true. Well, that´s about it. Of course, I´m struggling along trying to keep afloat, and the replies I´ve had have all pointed in the right direction, I think. If you have any suggestions at all which could help, I´ll gratefully accept.
Thanks again..
|
|
|
|
|
Hello all.
In all the time I have worked with C++ / MFC I have usually created data-centric applications, so I'm full with apps using ATL OleDB and the ODBC classes (CRecordset et. al.). So, I usually simply bypass the CDocument, or store small ammounts of info there (like the current user's ID and encrypted connection strings).
This time, however, I've been instructed to build a full doc-view application, with all the bells and whistles. It's kinda a internal product, so it will be a desktop app with no connectivity, and the files the app generates must be shared to other users. So, a doc-view app.
I've been wondering, however, how to create the data model. I mean, I created a base class that inherits from CObject, implements serialization and has a GUID as a property and such. Then my model classes inherit from this one. Some of this classes have collections of another one as their child, and so on. Say:
class CEntity : public CObject
{
CGuid GetId() const; };
class CContact : public CEntity
{
};
class CMeeting : public CEntity
{
CArray<CContact*> m_objParticipants;
};
Here the thing is that a CContact object can be used elsewhere, so it is not owned by the CMeeting. So, I'm guessing that the CContact collection should be created in the CDocument-derived class, and so the CMeeting one should have only references to a) the CDocument and b) the contact's CGuid, so that it can search for the actual pointer when needed. This would mean that CDocument should have to serialize the object rather than CMeeting, and I'm thinking CMeeting should only serialize the CGuid value... or something similar.
Yet... it doesn't feel quite right, and I'm rather confused as to which approach to use. So, I was wondering if you CPians could help me with advises, experiencies and how you solved similar problems. Any comment will be really appreciated.
Cheers and thanks in advance.
|
|
|
|
|
I know how to make IE not prompt this error.
How can I compile and distribute a program that wont
trigger this warning? Please let me know.
|
|
|
|
|
|
Hi all,
i get the details of any file using IShellFolder2::GetDetailsOf method,its working fine for other files.
but fails in case of MS Office files of 2007 and upper version of MS Office.
please help me to get these details of these files.
thanks in advance.
|
|
|
|
|
Hello,
I´m trying to output a byte to parallel printer port using dev-c++. I´ve included dos.h and conio.h, and I´ve put inpout32.dll in the system32 dll folder, but when I try to compile, the compiler stops at the "using system" instruction. I`m not very experienced with C programming and am feeling my way around, as yet.What I´m trying to do is to send a signal which can be read by a PLC which will in turn open an automatic barrier to let a registered vehicle in.
Can anybody help me out?
Many anticipated thanks
Andrew
|
|
|
|
|