|
SHCreateDirectory can create the full path with just one call.
|
|
|
|
|
the window sdk's function to operation "*.ini", like function WritePrivateProfileString and more,it's very inconvenient.
so you can use this class in your program (if the section isn't exiting,it will create himself.)
#if !defined(AFX_OPINI_H__CE3F8B7B_1ACA_46CC_A91C_F8E23FA9B063__INCLUDED_)
#define AFX_OPINI_H__CE3F8B7B_1ACA_46CC_A91C_F8E23FA9B063__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include <afxwin.h>
class COPini
{
public:
static DWORD ReadString (char *section, char * key, char stringtoread[], char * filename);
static BOOL WriteString(LPCTSTR section, LPCTSTR key,char* stringtoadd, char *filename);
COPini();
virtual ~COPini();
};
#endif // !defined(AFX_OPINI_H__CE3F8B7B_1ACA_46CC_A91C_F8E23FA9B063__INCLUDED_)
#include "stdafx.h"
#include "OPini.h"
COPini::COPini()
{
}
COPini::~COPini()
{
}
void error(LPSTR lpszFunction)
{
CHAR szBuf[80];
DWORD dw = GetLastError();
sprintf(szBuf, "%s failed: GetLastError returned %u\n",
lpszFunction, dw);
MessageBox(NULL, szBuf, "Error", MB_OK);
ExitProcess(dw);
}
BOOL COPini::WriteString(LPCTSTR section, LPCTSTR key, char *stringtoadd, char *filename)
{
CHAR FilePath[255];
GetModuleFileName(NULL,FilePath,255);
(strrchr(FilePath,'\\'))[1] = 0;
strcat(FilePath,filename);
return ::WritePrivateProfileString(section,key,stringtoadd,FilePath);
}
DWORD COPini::ReadString(char *section, char * key, char stringtoread[], char * filename)
{
CHAR FilePath[255];
GetModuleFileName(NULL,FilePath,255);
(strrchr(FilePath,'\\'))[1] = 0;
strcat(FilePath,filename);
return ::GetPrivateProfileString(section, key,NULL,stringtoread,255,FilePath);
}
you can it like this:
#include <<OPini.h>>
int main()
{
char *p1 = "Hello";
char *p2 ;
COPini::WriteString("Section1", "KeyName1", p1, "SetInfo.ini");
COPini::ReadString("Section2" , "KeyName2", p2, "SetInfo.ini");
.....
}
Good Luck !
modified on Tuesday, May 4, 2010 6:29 AM
|
|
|
|
|
How does this help to create a non-existent folder structure? I think that SHCreateDirectoryEx() would be a better choice.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
I have some code that is not getting executed in release mode. The code is in appui3.cpp in microsofts library. The method is GetProfileInt. I am trying to read some prefereces from the registry. It is working in debug mode, but in release it doesn't seem to be going to the method therefore I am not getting expected data. I am compiling with the /ZI switch for debug info in release mode also. Using VS2008. Any ideas?
Thanks
Ray
|
|
|
|
|
You could try by disabling optimizations.
For reading data from the registry use the registry functions instead.
|
|
|
|
|
Yes I have disabled the optimization. Thanks for the input, but why is it still not executing this part of the code?
Ray
|
|
|
|
|
Ok, I have decided that the code is getting executed, its just that when I step through in release mode it doesn't show me the actual steps it is taking nor are the value of the variables in the debugger valid.
So back to my problem that prompted this message. My program gets an exception in release mode but not in debug, but if I can't step through the program or rely on the debug variables in release mode, then how do I find out what is causing the exception? I've turning on the debugging information /Zi, turned off optimization, and turned on generate debug info in the linker. Still can get no usefull info from the debugger in release mode. Any ideas?
Ray
|
|
|
|
|
Step through the code and see...
Steve
|
|
|
|
|
Since you have the source code, you can make a backup of it and then modify this file to help you debug. Use OutputDebugString() and the free dbgview from sysinternals.com (now MS). This works for release mode build.
|
|
|
|
|
My problem is that it never goes to this code in release mode. I've put a break point on it and it never hits it.
|
|
|
|
|
Ok, I have decided that the code is getting executed, its just that when I step through in release mode it doesn't show me the actual steps it is taking nor are the value of the variables in the debugger valid.
So back to my problem that prompted this message. My program gets an exception in release mode but not in debug, but if I can't step through the program or rely on the debug variables in release mode, then how do I find out what is causing the exception? Anyone???
Ray
|
|
|
|
|
So during install I'd like to be able to determine the FTP root directory.
Anyone know how??
Thanks!
ed
~"Watch your thoughts; they become your words. Watch your words they become your actions.
Watch your actions; they become your habits. Watch your habits; they become your character.
Watch your character; it becomes your destiny."
-Frank Outlaw.
|
|
|
|
|
Install of what? Root directory of what FTP? Where? I think you should provide much more information than that to get a usefull answer. Try explaining a bit what you want (i recommend editing your original post), good luck.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
|
|
|
|
|
The problem is figuring out what the root directory of the FTP server is on a machine. Of course how to ensure FTP is installed and running would probably be a bonus question!!
I'm just giving a peek into what I'm working on when speaking of an installer. The installer isn't the problem.
Thanks..
ed
~"Watch your thoughts; they become your words. Watch your words they become your actions.
Watch your actions; they become your habits. Watch your habits; they become your character.
Watch your character; it becomes your destiny."
-Frank Outlaw.
|
|
|
|
|
I think finding that out isn't so trivial...i mean, there are probably tonns of FTP server softwares out there, each of them storing its root folder setting differently, in the registry, in some ini file, and so on... your best bet would be to make a connection to the FTP server but i don't know if the FTP protocol can tell you where the root folder is located on the local system. Also, as far as i know there might be different FTP root folders depending on the user who logs onto the server, so which one of the users would you want to use? I don't know much about installers, i hope someone else will give you a better answer.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
|
|
|
|
|
Actually an ftp server should never tell a client what his root directory is, for security reasons. Some ftp servers don't even have a root directory, but have virtual roots, usually spread out over a number of nfs servers, for redundancy and performance.
If you're talking about the 'standard' ftp server that comes with IIS, it's root location will be in the registry and you may find it during an install. But it won't do you much good: it may be somewhere where you have no access, it may be on a network for which you have no credentials, it may be on a reparse point, it may be on a symbolic link, all situations that may trick into thinking you may do something with it, only to find it causes failure.
|
|
|
|
|
Ed K wrote: Of course how to ensure FTP is installed and running would probably be a bonus question!!
Do you know the name of the FTP service?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Cha-Ching!!! Thanks!!!
ed
~"Watch your thoughts; they become your words. Watch your words they become your actions.
Watch your actions; they become your habits. Watch your habits; they become your character.
Watch your character; it becomes your destiny."
-Frank Outlaw.
|
|
|
|
|
Install what ? where ? and why does an install program should know about the FTP server?
Do you need to configure something on the user's FTP site ?
Watched code never compiles.
|
|
|
|
|
Maximilien wrote: Install what ? where ? and why does an install program should know about the FTP server?
Lesson learned today: Never hint at what the project actually does because it's really irrelevant and developers go there first! I'd probably do the same thing...
How can I find the root directory for an FTP server? (IIS) I've checked the registry.. not there. Not sure where else it could be stored.. Possibly a configuration file somewhere??
ed
~"Watch your thoughts; they become your words. Watch your words they become your actions.
Watch your actions; they become your habits. Watch your habits; they become your character.
Watch your character; it becomes your destiny."
-Frank Outlaw.
|
|
|
|
|
I'm using a ListView to display certain data, yet I can't select the row!
This is the DWORD style used in CreateWindow:
WS_CHILD|LVS_REPORT|LVS_EX_DOUBLEBUFFER|LVS_SINGLESEL|WS_TABSTOP|WS_VISIBLE
The only selection can only be done on Item, but not any of the SubItems.
|
|
|
|
|
Because you have not set the LVS_EX_FULLROWSELECT style.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
WS_CHILD|LVS_REPORT|LVS_SINGLESEL|LVS_EX_GRIDLINES|LVS_EX_FULLROWSELECT|LVS_EX_DOUBLEBUFFER|WS_VISIBLE
Still no changes everything is still the same!
|
|
|
|
|
You need to change these settings with something like :
SendMessage(hWndView,
LVM_SETEXTENDEDLISTVIEWSTYLE,
LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES,
LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES
);
in your view initialization code. Take a look at the MSDN documentation for LVM_SETEXTENDEDLISTVIEWSTYLE .
It's time for a new signature.
|
|
|
|
|
Hy . I want to build my CSmtp client MFC compatible class , and for that I need to call gethostbyname , but here I'm stuck ... because I use CString , and function parameter is 'const char FAR *' ... my questions is : how can I convert CString to const char * ?
P.S. If you know some SMTP client tutorial , it will be very good ! Thank you !
|
|
|
|