|
I have to create a propeties file which I would be using in my program. Please help me how should I create a properties file.
thanks.
|
|
|
|
|
What do you mean properties file? Are you talking about writing program setting to a file? If that is that case then you can use ini file (this[^] article makes it east to do so) or you can use XML file. Lot of programs also use windows registry to save their settings.
-Saurabh
|
|
|
|
|
I m new in windows programer.
Anyway, Still i m confuse regarding this.forget aboout linux temporary.
I want to write client socket application using c,c++ language on windows platform on vc++(vc++ console application or win32 static library).
i dont want to use any Winsock API or MFC class for creating and connecting socket.
because when i create socket using winsock API and after that if i use
SSL_read() on the fd retured by winsock API, then it will not working.
for simplicity,
IS it possible to write openssl -based client socket application using c,c++ on windows-vc++ platform without using any winsock class and MFC class
if possible then what i have to do
(1) what openssl version i have to use for windows
(2) what API i have to use for creating socket,connecting socket, reading data and writing data.
right now i m creating socket like this in window using vc++ . I m using window XP
int sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP) I think in window socket() is defined in winsock.h
now i how i use SSL functionality.
whethere SSL_read() support fd return by WINSOCK API socket. if not then what is the solution.
sorry i m again editing my query.right now i m using
socket() and connect() in vc++(window) then internally they are using winsock only.
now tell me instread of
socket() and connect() what i have to use so that i can use SSL_read and SSL_write()
Regards,
Amit
Regards,
Amit
Edit/Delete Message
modified on Thursday, April 24, 2008 7:40 AM
|
|
|
|
|
AFAIK there's no SSL support in the Windows Sockets library (Winsock).
If you want to roll your own, you'll need to thouroughly understand how SSL works.
Have you looked into using OpenSSL[^]?
Since you have OpenSSL in the topic of this post...um, why aren't you using
the openssl functions for this?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
thx Mark for replying me.
I want to write client application on windows operating sysystem(vc++) .
suppose if i creat follow the steps
I m writing steps for client below
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <fcntl.h>
#include <errno.h>
#include <winsock2.h>
#include
#include
#include
#include
#include
#include
(1) create the socket
sock = (sock=socket(AF_INET,SOCK_STREAM,IPPROTO_TCP)
(2) connect the socket to the host
connect (sock, (struct sockaddr*) &sa, sizeof (sa))
(3) now my dought comes,
i want to use openssl API on the socket descriptor sock shown in the above step returned by socket() and connect() of Winsock2.h
steps for this are:
SSL_library_init();
SSL_load_error_strings();
SSLeay_add_ssl_algorithms();
meth = SSLv23_client_method();
ctx = SSL_CTX_new (meth);
SSL_CTX_set_options(ctx,0);
SSL_CTX_set_verify(ctx,SSL_VERIFY_NONE,NULL);
X509_STORE* store = SSL_CTX_get_cert_store(ctx);
X509_STORE_set_flags(store, 0);
ssl = SSL_new (ctx);
BIO* sbio=BIO_new_socket(conn_fd,BIO_NOCLOSE);
SSL_set_bio(pDialerCB->ssl,sbio,sbio);
SSL_set_connect_state(pDialerCB->ssl);
printf("SSL set connect state\n");
peer=SSL_get_peer_certificate(ssl);
after that SSL_read() and SSL_write()
tell me whethere its work or not
Regards,
Amit
|
|
|
|
|
|
Hello,
I am new in WinCE development.
I have to create a hook which monitors foreground windows. If internet explorer window come to foreground then I have to invoke a dialog box.
For that I tried to create hook using SetWinEventHook API which is not supported directly by WinCE.
So we have to update some declarations using winuser.h (general Windows XP, Vista, etc) and have to load coredll.dll
I had tried and getting following errors –
Generating Code...
Compiling resources...
Linking...
MainFrm.obj : error LNK2019: unresolved external symbol "struct HWINEVENTHOOK__ * __cdecl SetWinEventHook(unsigned long,unsigned long,struct HINSTANCE__ *,void (__cdecl*)(struct HWINEVENTHOOK__ *,unsigned long,struct HWND__ *,long,long,unsigned long,unsigned long),unsigned long,unsigned long,unsigned long)" (?SetWinEventHook@@YAPAUHWINEVENTHOOK__@@KKPAUHINSTANCE__@@P6AXPAU1@KPAUHWND__@@JJKK@ZKKK@Z) referenced in function "protected: int __cdecl CMainFrame::OnCreate(struct tagCREATESTRUCTW *)" (?OnCreate@CMainFrame@@IAAHPAUtagCREATESTRUCTW@@@Z)
Windows Mobile 5.0 Pocket PC SDK (ARMV4I)\Release/ScureApp.exe : fatal error LNK1120: 1 unresolved externals
Please have a quick look on my code as follows -
my MainFrm :: OnCreate() contains
g_hHkApiDLL = LoadLibrary(_T("user32.dll"));
g_hHkApiDLLBox = LoadLibrary(_T("coredll.dll"));
if((g_hHkApiDLLBox && g_hHkApiDLL) == NULL)
{
AfxMessageBox(_T("Error to load coredll.dll"));
//something is awfully wrong
//the dll has to be present
return false;
}
else
{
//load the SetWindowsHookEx API call
//the SetWindowsHookEx function installs an application-defined hook procedure into a hook chain.
//You would install a hook procedure to monitor the system for certain types of events.
//here we use use the hook to monitor kyeboard events
LPTSTR pSetWinEventHook;
pSetWinEventHook = (LPTSTR)GetProcAddress(g_hHkApiDLLBox, _T("SetWinEventHook"));
if(pSetWinEventHook == NULL)
{
AfxMessageBox(_T("Error to install hook procedure"));
//this means that MS has really stopped supporting this API in WinCE
return false;
}
else
{
//SetWindowRetProcHook (TRUE);
// hEvtHook = SetWinEventHook (EVENT_MIN, EVENT_MAX,
hEvtHook = SetWinEventHook (EVENT_SYSTEM_FOREGROUND, EVENT_SYSTEM_FOREGROUND,
NULL, ForegroundProc, 0, 0,
WINEVENT_OUTOFCONTEXT);
}
}
My ForgroundProc as follows -
VOID CALLBACK ForegroundProc( HWINEVENTHOOK hWinEventHook, DWORD event, HWND hwnd,LONG idObject, LONG idChild, DWORD dwEventThread, DWORD dwmsEventTime )
{
AfxMessageBox(_T("Inside ForegroundProc"));
TCHAR buf[MAX_PATH];
HWND hWndForeGroundWin = GetForegroundWindow();
if (GetClassName(hWndForeGroundWin, buf, MAX_PATH))
{
if (!_tcsicmp (buf, TEXT("IEFRAME")) ||
_tcsstr (buf, TEXT("Internet Explorer")) ||
!_tcsicmp (buf, TEXT("MozillaUIWindowClass")))
{
AfxMessageBox(TEXT("Found Internet Explorer"));
}
}
}
Also we have declared in header .h file -
HINSTANCE g_hHookApiDLL = NULL; //handle to coredll.dll, where all the hook related APIs are present
HHOOK g_hInstalledLLKBDhook = NULL; //g_hInstalledLLKBDhook represents handle to the installed KB hook
#define EVENT_SYSTEM_FOREGROUND 0x0003
#define WINEVENT_OUTOFCONTEXT 0x0000 // Events are ASYNC
typedef VOID (CALLBACK* WINEVENTPROC)(
HWINEVENTHOOK hWinEventHook,
DWORD event,
HWND hwnd,
LONG idObject,
LONG idChild,
DWORD idEventThread,
DWORD dwmsEventTime);
//typedef HWINEVENTHOOK (WINAPI *SetWinEventHook)(DWORD, DWORD, HMODULE, WINEVENTPROC, DWORD, DWORD, DWORD);
//extern "C"
WINUSERAPI
HWINEVENTHOOK
WINAPI
SetWinEventHook(
__in DWORD eventMin,
__in DWORD eventMax,
__in_opt HMODULE hmodWinEventProc,
__in WINEVENTPROC pfnWinEventProc,
__in DWORD idProcess,
__in DWORD idThread,
__in DWORD dwFlags);
Now request you, please look into the code, and suggest me where I am getting wrong.
Thanks.
Regards,
Shashikant
|
|
|
|
|
Woah, woah
What are you trying to do there ?
Shashi.Shinde wrote: For that I tried to create hook using SetWinEventHook API which is not supported directly by WinCE.
If it is not supported on winCE, then it is not supported. You can't expect to load a dll that was built for windows (desktop) on winCE because these are two different platforms. You can't use a dllthat was compiled for windows on WinCE.
|
|
|
|
|
Thank you for your interest in this post.
Well,
we have modified our code using the article http://www.codeproject.com/KB/mobile/wincekbhook.aspx[^]
and created a keyboard hook using Windows Mobile 5.0 Pocket PC SDK. and we are able to invoke that hookproc using SetWindowsHookEx API which is not supported by windows (desktop) by loading coredll.dll and some declarations with respect to winuser.h windows (desktop).
Now, I am trying to use SetWinEventHook API to trap Foregroundwindow.
If there is any other way to monitor foreground window. Then please let me inform.
Thank you.
Regards,
Shashikant
|
|
|
|
|
I probably misunderstood your post, you are probably loading the WinCE dll.
Anyway, looking at your first post, the way you are calling the function is wrong: you should use the address you retrieved from GetProcAddress (so pSetWinEventHook instead of SetWinEventHook).
And please, next time use the formating tags because your code is barely readable.
|
|
|
|
|
Shashi.Shinde wrote: hEvtHook = SetWinEventHook (EVENT_SYSTEM_FOREGROUND, EVENT_SYSTEM_FOREGROUND,
NULL, ForegroundProc, 0, 0,
WINEVENT_OUTOFCONTEXT);
There are some mistakes in your code. To dynamically call the SetWinEventHook function, follow the below code. Also those modification in the winuser.h is not needed...
typedef HWINEVENTHOOK (WINAPI *SetWinEventHookDef)(DWORD, DWORD, HMODULE, WINEVENTPROC, DWORD, DWORD, DWORD);
SetWinEventHookDef pSetWinEventHook = (SetWinEventHookDef)GetProcAddress(g_hHkApiDLLBox,
_T("SetWinEventHook"));
if(pSetWinEventHook == NULL)
{
AfxMessageBox(_T("Error to install hook procedure"));
return false;
}
else
{
hEvtHook = pSetWinEventHook(EVENT_SYSTEM_FOREGROUND,
EVENT_SYSTEM_FOREGROUND,
NULL, ForegroundProc, 0, 0,
WINEVENT_OUTOFCONTEXT);
}
|
|
|
|
|
Hello Nave,
Thank you very much for your valuable and instant reply.
Now, I had updated my application as per above code (your posted), All compiler / linker errors are gone out. But, after running, I am getting message - "Error to install hook procedure". You written above - this means that MS has really stopped supporting this API in WinCE.
So request you if you found any procedure to monitor foregroundwindow then let me know.
Also I like to tell you that SetWindowsHookEx will get support in WinCE if follows this link - http://www.codeproject.com/KB/mobile/wincekbhook.aspx[^]
Thanks again.
Regards,
Shashikant
|
|
|
|
|
Hi all,
I am reading IUpdateDownloader at msdn because I have a project regarding autoupdate of software. Now my task as of the moment is to know how to download from a site to a client automatically just like microsoft update. When the service downloads the update but doesnt finish lets say 50% when the client connects again to the net the download must resume at 50%. Anybody knows how to do this? Even the basics of IUpdateDownloader?
thanks,
Jj
|
|
|
|
|
i had actually asked aquery some days back.. but there was no much response.
this is on merging files.
There is a huge file which is split into 4 files so that we can use it in excel. now i want to merge the whole file into one. i have actually merged the file. but i want to avoid the first line of every file except the first file. how do i do that?
will send u the code of how i have done the merge. this might not be the right way to do the merging.. but its working for me,
<br />
#include<stdio.h><br />
void main()<br />
{<br />
FILE *fp,*fp1,*fp2;<br />
char ch;<br />
fp = fopen("4.dat","r");<br />
fp1 = fopen("final.dat","w");<br />
<br />
while(1)<br />
{<br />
ch = fgetc(fp);<br />
if(ch ==EOF)<br />
break;<br />
else<br />
fputc(ch,fp1);<br />
}<br />
fclose(fp);<br />
fclose(fp1);<br />
<br />
<br />
fp2 = fopen("5.dat","r");<br />
fp1 = fopen("final.dat","a+");<br />
while(1)<br />
{<br />
ch = fgetc(fp2);<br />
if(ch ==EOF)<br />
break;<br />
else<br />
fputc(ch,fp1);<br />
}<br />
<br />
fclose(fp2);<br />
fclose(fp1);<br />
<br />
fp2 = fopen("6.dat","r");<br />
fp1 = fopen("final.dat","a+");<br />
while(1)<br />
{<br />
ch = fgetc(fp2);<br />
if(ch ==EOF)<br />
break;<br />
else<br />
fputc(ch,fp1);<br />
}<br />
<br />
fclose(fp2);<br />
fclose(fp1);<br />
<br />
fp2 = fopen("7.dat","r");<br />
fp1 = fopen("final.dat","a+");<br />
while(1)<br />
{<br />
ch = fgetc(fp2);<br />
<br />
if(ch ==EOF)<br />
break;<br />
else<br />
fputc(ch,fp1);<br />
}<br />
<br />
fclose(fp2);<br />
fclose(fp1);<br />
<br />
}<br />
<br />
please give me a solution for this. <br />
<br />
<br />
<br />
<br />
</stdio.h>
|
|
|
|
|
To avoid first line copy: just discard read characters up to line terminator (i.e. '\n' )
BTW what about a bit refactoring?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
is there anything wrong in what i have done?? and i would rather go for the first option that bit refactoring...
|
|
|
|
|
Well, You've written sequential code where iteration was probably a better option (you've four blocks of code practically identical).
Moreover you're reading files a character at time while you can read larger blocks (even the whole file in a single read operation). The same for the writing.
BTW my suggestions weren't mutually exclusive.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Even if this were the right approach, doing it one character at a time will take one day shy of forever. If your files are line-delimited, at least try and use fgets() .
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi all,
I have two exe's. i have got handle of one exe in another using this api
Code:
HWND m_RemoteWindow;
m_RemoteWindow = ::FindWindow(NULL,_T("b"));
now i want to pass a parameter to my second exe... i have got handle for it...
How can i do so.....
I have to pass parameter from one exe to another and retrieve that parameter in second exe
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
This is basically an IPC issue.
For a simple approach see Using Data Copy ^.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
It is window handle, not exe handle. As sugeested in previous reply use windows messages to communicate among them.
|
|
|
|
|
Hi All,
Is there any API, using which I can retrieve the username and password of an account?
Thank you,
AJ
|
|
|
|
|
Yes and it even works for remote machines.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
CPallini wrote: Yes and it even works for remote machines.
wats that API ???
|
|
|
|
|
What would have happened to the Windows Security then...
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|