15,919,423 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by Member 12891988 (Top 15 by date)
Member 12891988
6-Apr-17 11:38am
View
One last thing, side c#,
I receive data normally using this:
byte[] buffer = new byte[1500];
int iRx = sck.Receive(buffer);
char[] chars = new char[iRx];
System.Text.Decoder d = System.Text.Encoding.UTF8.GetDecoder();
int charLen = d.GetChars(buffer, 0, iRx, chars, 0);
System.String szData = new System.String(chars);
and then I print in listview like so:
listView1.Items.Add(szData)));
-----------------------------------------
But if I have to create the Icon, I have to use DIBSECTION ds to create the image/icon;
width = ds.dsBm.bmWidth;
height = ds.dsBm.bmHeight;
stride = ds.dsBm.bmWidthBytes;
ecc...
But how I can convert byte that I have received to DIBSECTION ds?
So if I convert byte array to ds I can use ds to create the Icon.
Member 12891988
6-Apr-17 8:07am
View
thank you
Member 12891988
6-Apr-17 6:49am
View
You think this should be correct?
I have substituted that condition with tihs if:
if(!nSizeDS){//failure}
else{//is a DIB}
here there the complete part of code:
ICONINFO oIconInfo;
if (::GetIconInfo(icon, &oIconInfo))
{
// Get bitmap info for colour mask
DIBSECTION ds;
int nSizeDS = ::GetObject(oIconInfo.hbmColor, sizeof(ds), &ds);
if(!nSizeDS){
cout <<"Failure!"<<endl;
}else{
// is a DIB
cout <<"Success!"<<endl;
// Send the DIBSECTION
send(newConnection, (CHAR*)&ds, sizeof(ds), NULL);
// Send raw bitmap
send(newConnection, (CHAR*)ds.dsBm.bmBits, ds.dsBmih.biSizeImage, NULL);
}
}
Member 12891988
6-Apr-17 6:25am
View
When I try that piece of code,the if (sizeof(ds) == nSizeDS) condition, isn't ever verified.
How about using the two send without this if (sizeof(ds) == nSizeDS) ?
In this case without the if condition works, but I'm afraid this should be wrong.
Member 12891988
6-Apr-17 6:12am
View
Yes sorry I read, and I have deleted this last my question from here, but maybe to late.
Member 12891988
6-Apr-17 6:03am
View
Thanks a lot Jochen I will try.
Member 12891988
6-Apr-17 5:58am
View
Deleted
It means that I have to send via socket: ds.dsBmih and oIconInfo?
like this:
send(newConnection,(CHAR*)&ds.dsBmih,sizeof(ds.dsBmih),NULL);
send(newConnection,(CHAR*)&oIconInfo,sizeof(oIconInfo),NULL);
And via c# getting: width, height, stride, colour depth, and byte array, from ds.dsBmih that I have received from server, or in the server I have to do multiple sending?
One sending for width,one for height,one for stride, ecc...
I do not understood this
Member 12891988
6-Apr-17 5:45am
View
I've tryed this, but I do not know How to continue:
ICONINFO oIconInfo;
DIBSECTION ds;
if(::GetIconInfo(icon, &oIconInfo)==true){
HBITMAP hBitmap = oIconInfo.hbmColor;
int nSizeDS = ::GetObject(hBitmap, sizeof(ds), &ds);
// hBitmap is a DIB
if (0 == ds.dsBmih.biSizeImage)
{
if (0 == ds.dsBm.bmWidthBytes)
ds.dsBm.bmWidthBytes = ((ds.dsBm.bmWidth * ds.dsBm.bmBitsPixel + 31) & ~31) / 8;
ds.dsBmih.biSizeImage = ds.dsBm.bmHeight * ds.dsBm.bmWidthBytes;
}
send(newConnection,(CHAR*)&oIconInfo,sizeof(oIconInfo),NULL);
}
Member 12891988
6-Apr-17 5:15am
View
Hi, thanks and sorry but I have not to understood well you example, more exactly I do not understood what I should send to client via socket.
I tryed to do this:
HICON icon = (HICON)GetClassLong(hWnd, GCL_HICON);
ICONINFO oIconInfo;
if(::GetIconInfo(icon, &oIconInfo)==true){
cout <<"Success!"<<endl;
send(newConnection,(CHAR*)&oIconInfo,sizeof(oIconInfo),NULL);
}else{
cout <<"Failure!"<<endl;
}
But I do not know how to send the other that you said.
Can You give a simple example combining with my little solution?
PS. I need to do multiple sending?
Before I send this:
send(newConnection,(CHAR*)&oIconInfo,sizeof(oIconInfo),NULL);
and then I send:
BITMAPINFOHEADER bitmapinfoheader;
send(newConnection,(CHAR*)&bitmapinfoheader,sizeof(bitmapinfoheader),NULL);
I do not know how can do in practically.
Member 12891988
5-Apr-17 18:32pm
View
Thanks a lot, I think to have solved about send in server side:
HICON icon = (HICON)GetClassLong(hWnd, GCL_HICON);
ICONINFO oIconInfo;
if(::GetIconInfo(icon, &oIconInfo)==true){
cout <<"Success!"<<endl;
send(newConnection,(CHAR*)&oIconInfo,sizeof(oIconInfo),NULL);
}else{
cout <<"Failure!"<<endl;
}
Now I have to convert the stream of byte read from my client(this is made in c#) that I have received from my c++ server, and convert the array of bytes to an Image.
So I have tried to do this:
byte[] buffer = new byte[1500];
sck.Receive(buffer);
TypeConverter tc = TypeDescriptor.GetConverter(typeof(Bitmap));
Bitmap bitmap1 = (Bitmap)tc.ConvertFrom(buffer);
imageList1.Images.Add(bitmap1);
When I try this, I receive an error at this line:
Bitmap bitmap1 = (Bitmap)tc.ConvertFrom(buffer);
This is the message error that I have received:
Unhandled exception of the 'System.ArgumentException' type System.Drawing.dll
Additional information: Invalid parameter.
I have also tried:
MemoryStream ms = new MemoryStream(buffer);
Bitmap bmp;
bmp = new Bitmap(ms);
and this other:
ImageConverter ic = new ImageConverter();
System.Drawing.Image img = (System.Drawing.Image)ic.ConvertFrom(buffer);
Bitmap bitmap1 = new Bitmap(img);
but I have received the same error message.
Member 12891988
18-Mar-17 6:57am
View
Hi,I need one more advise, I am aware that there are ways to check if a process is already running (via enumeration). However, I was wondering if there was a way to listen for when a process starts and ends (for example, notepad.exe) and then perform some action when the starting or ending of that process has been detected. I assume that one could run a continuous enumeration and check loop for every marginal unit of time, but I was wondering if there was a cleaner solution.
Thancks in advance
Regards
Member 12891988
18-Mar-17 6:11am
View
Hi,I need one more advise, I am aware that there are ways to check if a process is already running (via enumeration). However, I was wondering if there was a way to listen for when a process starts and ends (for example, notepad.exe) and then perform some action when the starting or ending of that process has been detected. I assume that one could run a continuous enumeration and check loop for every marginal unit of time, but I was wondering if there was a cleaner solution.
Thancks in advance
Regards
Member 12891988
14-Mar-17 10:31am
View
Thank you so much for your help.
I will try.
Regards
Member 12891988
14-Mar-17 5:59am
View
I do not know how to send a command from keyboard to interact with process on focus.
For example: I have in the server side machine firefox opened and when I press ctrl*f from my keyboard a searching bar was opened.
So I would do the same thing, but pushing ctrl+f from my client machine and open searching bar in firefox installed on server machine.
I just want to use command from my keyboard to interact with a window application.
and after I do not push enter or send,I only want that: if I push ONLY ctrl server must receive it, if i push ctrl+f server must receive it and so on.
Member 12891988
14-Mar-17 4:49am
View
Thanks for your reply.
I do not know how I can send a command(ctrl+c for example) from client to the server.
I know how send a buffer of char or string but I do not know how I can send a combination of key from keyboard.
Show More