|
Problem: Hi Iam using std::string to do all operations with string,
Now i want to support UNICODE how can i change it to UNICODE support.
Thanks in advance
----------------------------
KRISHNA KUMAR T M
|
|
|
|
|
std::string doesn't not support UNICODE. If you want to use unicode strings, you have to use std::wstring instead.
If you want support for both, you will need to define your own type, something like that:
#if defined _UNICODE || defined UNICODE
typedef std::wstring TMyString;
#else
typedef std::string TMyString;
#endif
And then everywhere in your code you use TMyString instead of std::string.
|
|
|
|
|
|
Hi,
I am working with COM dll resources. I have created a menu in a com dll and provided an interface with a method to return the handle to the menu.
When I am trying to pass this handle(converting to int) to CSingleDocTemplate of InitInstance() and trying to run the application, I am getting "Failed to create empty document".
My intention is to use the menu(resource) which is present in the com dll in my application.
In order to achieve this, is this the correct way of proceeding or not? If yes, where am I doing wrong?
If not, please suggest an alternative mechanism.
Thanks in advance.
Taruni
|
|
|
|
|
Hi! all
I was working on a project which is completed few weeks ago. This project was developed using Windows Form Application in Visual Studio 2005. We have some standard coding architecture on which we develop all projects.
There are some header files which need to be included in project.My task is to encode these header files so that any body can not directly access and change these files. I have tried to convert them in .lib and include it project but not successful yet.
So is there any way to protect these files, without any disturbance in project compilation. Can we convert these header files in .lib or encrypt them in other way.
Please help me.................
Thanks and regards,
Nitin
|
|
|
|
|
well, al I can think of is make them Read Only, put them on a CD, Store them on a Server with Readonly Access, Put dire consequences to unauthorized changes (e.g. Sacking on the Spot).
The header files contain the declarations etc that the compiler uses to build the symbol table to access objects correctly in the .lib files, so the Compiler MUST be able to read them, and encoding is therefore not an option.
Any programmes worth his salt should know that it is a BAD idea to change a header file belonging to a pre-compiled lib.
regards,
Bram van Kampen
|
|
|
|
|
|
I had to do this a while ago, and here's a snippet of code:
DWORD CNamedPipeServer::ServerThread ()
{
SECURITY_ATTRIBUTES sa;
SECURITY_DESCRIPTOR sd;
if (!InitializeSecurityDescriptor (&sd, SECURITY_DESCRIPTOR_REVISION))
return 0;
SetSecurityDescriptorDacl (&sd, TRUE, NULL, FALSE);
sa.nLength = sizeof (sa);
sa.bInheritHandle = FALSE;
sa.lpSecurityDescriptor = &sd;
BOOL bLog = FALSE;
char pipename [512];
lstrcpy (pipename, "\\\\.\\pipe\\");
lstrcat (pipename, m_PipeName);
m_hPipe = ::CreateNamedPipe (pipename,
PIPE_ACCESS_DUPLEX | FILE_FLAG_WRITE_THROUGH | FILE_FLAG_OVERLAPPED,
PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT,
1, 0, 0, 100000, &sa);
if (m_hPipe == NULL)
{
TRACE1("Could not start '%s'\n", pipename);
return -1;
}
m_PipeName was the friendly part of the name. I'd use a GUID nowadays, but this was 8-years-ago-Iain. I would also do it unicode too...
To connect, just:
BOOL CNamedPipe::Open (LPCSTR szName, LPCSTR szMachine)
{
Close ();
m_dwError = ERROR_FILE_NOT_FOUND;
if (szName == NULL)
return FALSE;
CString tmp ("\\\\");
tmp += (szMachine && lstrlen (szMachine) > 1) ? szMachine : ".";
tmp += "\\pipe\\";
tmp += szName;
m_hPipe = ::CreateFile (tmp, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL);
if (m_hPipe == INVALID_HANDLE_VALUE)
{
m_dwError = ::GetLastError ();
return FALSE;
}
Where szName matches the server name, and szMachine is (oddly enough) the machine address. For initial debugging, maybe try a raw IP address?
My bet is that you'll need the blank security descriptor bit from above.
Iain.
|
|
|
|
|
Iain Clarke wrote: Where szName matches the server name, and szMachine is (oddly enough) the machine address. For initial debugging, maybe try a raw IP address
Worth a try if the security bit does not do the trick.
Iain Clarke wrote: My bet is that you'll need the blank security descriptor bit from above.
Well what you say seems to make sense. I used NULL for the Security Attribute Pointer. I put your bit in, and will try it tomorrow on the Network. I'll let you know how I get on. BTW Does this mean that the pipe this way is also potentially accessible from the Internet?
Thanks a Lot
Bram van Kampen
|
|
|
|
|
Bram van Kampen wrote: Does this mean that the pipe this way is also potentially accessible from the Internet?
Well, in the case I was working on the pipe was on a secondary PC, accessible only from a network between it and the primary PC. But as far as the pipe is concerned, it won't care how far a packet has to come. Your issues are more to do with firewalls and routing.
That said, I wouldn't dream of using a named pipe for working over the internet - just simply because of how flaky the big bad world is. Dropped connections, lags, etc. And windows only, I'd think (for all I know, someone has done a bang up job of writing a unix clone).
Iain.
|
|
|
|
|
Iain Clarke wrote: That said, I wouldn't dream of using a named pipe for working over the internet - just simply because of how flaky the big bad world is. Dropped connections, lags, etc. And windows only, I'd think (for all I know, someone has done a bang up job of writing a unix clone).
Exactly my concern. But, as you said, this is a Firewall Issue.
Tried your suggestion, and the error moved from 'cannot open pipe' to 'cannot read pipe'. so it appears to be the right path to a solution. The confusing thing is that all works propperly if ran on a single machine.
Thanks for your help.
Bram van Kampen
|
|
|
|
|
Having said the above,tried a lot of things.I am testing on a test site with 3 computers and no internet connection, No security risks, and No security impediments on the computer of any kind I'm aware off.Everybody is now signed on as administrator, Still, Pipes do not Work! Any Ideas, or should I re-design and implement on connection level.
Kind Regards,
Bram van Kampen
|
|
|
|
|
Is there any sample project or any easy way to move data
to Outlook? Im looking for a sample project that would
transfer anything to Outlook and I could expand and customize
on that.
Please any response any one can give me will be greatly
appreciated.
Sincerely,
Danielle Brina (an overworked graduate student)
|
|
|
|
|
Outlook has a COM interface that you can get to through its type library.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
What exactly does that mean? Any chance you have an
example of transferring some data to it?
Please, any response you can give me will be greatly
appreciated.
Sincerely,
Danielle Brina
|
|
|
|
|
_Application app;
if (app.CreateDispatch("Outlook.Application") == TRUE)
{
_NameSpace ns = app.GetNamespace("MAPI");
ns.Logon(...);
...
ns.Logoff();
} You can consult VBAOL11.chm and here for more.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
( lang: C/C++. platform: windows )
Hi, I want to do the following from my win32 app (could be mfc or whatever):
1) Call php.exe, send as command line parameter the name of a .php script to execute.
2) The console window must not show up.
3) (optional) Grab php's output.
An alternative to 3) would be executing something like "php.exe script.php > temp_output.html" and then reading temp_output.html
I've tried ShellExecute(), CreateProcess() and System(), all of which show the console window, and with none of them I've been able to capture the process' output.
Any [ hints | tutorials | code | help ] would be appreciated!
Thanks!
|
|
|
|
|
SECURITY_ATTRIBUTES sa = {sizeof(sa),NULL,TRUE};
HANDLE hProcOut = CreateFile("proc.out",GENERIC_READ|GENERIC_WRITE,
FILE_SHARE_READ,&sa,CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
.
.
.
STARTUPINFO si;
ZeroMemory((PVOID)&si,sizeof(si));
si.cb = sizeof(si);
si.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES;
si.wShowWindow = SW_HIDE;
si.hStdOutput = hProcOut;
si.hStdError = hProcOut;
PROCESS_INFORMATION pi;
if (CreateProcess(0,cmd,0,0,TRUE,
CREATE_DEFAULT_ERROR_MODE,0,default_dir,&si,&pi)) {
DWORD ExitCode;
float elpsed_crnt=0;
while (1) {
Sleep(250);
GetExitCodeProcess(pi.hProcess,&ExitCode);
if (bCancel || (ExitCode != STILL_ACTIVE)) {
if (bCancel) TerminateProcess(pi.hProcess,0);
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
break;
}
}
}
|
|
|
|
|
Probably should add that whole thing is running in a seperate thread from the UI. (CreateThread, etc.)
|
|
|
|
|
I think CFrameWndEx is cool, and try to use it in one project that
doesn't need to be SDI.
I have tried to derive a class from it, but that doesn't work.
CreateEx() always fails.
Any suggestions ?
|
|
|
|
|
lingol wrote: that
doesn't need to be SDI.
You need to explain that. It doesn't need to have data that the view renders in any way? Then what does the view render?
led mike
|
|
|
|
|
I'm writing a simple IM software as a network homework.
All it needs are a box to send, a box to receive and a list of friends.
It will be better if user can resize the two boxs by moving the "bar" between them,
and hide/show the friend list easily.
It seems that only CFrameWndEx can do the job, and there's no reason why I should
make it SDI.
Maybe I take the SDI framework wrong?
<div class="ForumMod">modified on Tuesday, November 18, 2008 8:08 PM</div>
|
|
|
|
|
lingol wrote: Maybe I take the SDI framework wrong?
Seems so. The Document/View framework is sort of a kluged MVC implementation, but can be viewed as such none the less. If you don't need the user to operate with files then don't implement those features. That does not mean that you can't use the design of the Document-View where the Document is like the Model in Model-View-Controller.
led mike
|
|
|
|
|
So that's why MS doesn't provide "CDialogEx"?
|
|
|
|
|
|