5 Replies - 875 Views - Last Post: 19 July 2016 - 08:31 PM

#1 JacobH  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 26
  • View blog
  • Posts: 176
  • Joined: 07-September 15

Looking for input on my content

Posted 18 July 2016 - 06:34 PM

Hi,

I've been wanting to write up some content on C# and I wrote my first entry the other week here https://lolp1blog.wo...-invoke-system/

It got about a thousand views and I enjoyed the response. I'm looking for any ideas to write about or how to improve content posted. As always, I will return the favor to this website in the form of content here such as my tutorials :)/> converting the pinvoke one to this forms tags as we speak.

This post has been edited by JacobH: 18 July 2016 - 06:35 PM


Is This A Good Question/Topic? 0
  • +

Replies To: Looking for input on my content

#2 Curtis Rutland  Icon User is offline

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 5101
  • View blog
  • Posts: 9,283
  • Joined: 08-June 10

Re: Looking for input on my content

Posted 19 July 2016 - 07:23 AM

My issue with your article is that you introduce the concept of p/invoke and the Win32 API, but you don't really explain what it is, or why we would actually want to use it. You basically leave it at "this is how to call unmanaged code" without getting into what that means. And since the Win32 API is the largest use for p/invoke, it's probably worth explaining what the Win32 API is and some of the things you can do with it, beyond just how to use it.
Was This Post Helpful? 0
  • +
  • -

#3 JacobH  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 26
  • View blog
  • Posts: 176
  • Joined: 07-September 15

Re: Looking for input on my content

Posted 19 July 2016 - 02:19 PM

Thanks for the input. I am not really sure if I can agree that your point is an actual issue though. If I had to explain in that article what the Win32 API is, or why you would want to use it, then there is a 99.99% chance the reader is not ready to touch pinvoke stuff yet.

Even giving the benefit of the doubt that the reader was ready to make use of pinvoke despite not knowing what the Win32 API is or why it might even be useful, a quick google search would return much more content on that specific subject than I could write up in my single-topic article. What benefit is gained from including it in my content?

It's not really like it is a Hello World console app, you know? Some degree of experience with using a desktop computer and writing practically any windows application in any language is assumed. Even basic auto-it scripts would have introduced some one to the Win32 API and its benefits. Pinvoke is not the place to start down that road in my eyes.

This post has been edited by JacobH: 19 July 2016 - 02:19 PM

Was This Post Helpful? 0
  • +
  • -

#4 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 13392
  • View blog
  • Posts: 53,445
  • Joined: 12-June 08

Re: Looking for input on my content

Posted 19 July 2016 - 02:34 PM

I know I kick back plenty of tutorial submissions with that being a chief reason.

Sure, if you were a dictionary and I was looking up specific information on X maybe have a little less fluff.. With your case you are a website. At the least, consider folks may be wandering around your page flipping through things at their leisure.. if they came across something that gives them a "why should I know this" into that may spark them to come back to it later or light a fire for them to research now.

Also, being a website, I figure content is fairly crucial for page rankings, right? If you have a few paragraphs explaining the 'why', 'what for' and 'potential uses' then that would expand some of the key words for searches, right? Right.

So a minor investment of time to flesh out a small paragraph dedicated to throwing a few hooks out there for a passer-by, or make it slightly more accessible someone looking at other related topics is well worth the effort.
Was This Post Helpful? 0
  • +
  • -

#5 IronRazer  Icon User is offline

  • Custom Control Freak
  • member icon

Reputation: 1432
  • View blog
  • Posts: 3,654
  • Joined: 01-February 13

Re: Looking for input on my content

Posted 19 July 2016 - 05:36 PM

Perhaps consider expanding it a little more since there is so much more to this subject, maybe a 2 or 3 page tutorial. I run into people using bad signatures or ones that have not been set up right all the time. I know you can not cover everything but, the more you explain and cover can help bring more people to your site. Here is a few things.

1. Include a little info on the DllImportAttribute class`s Fields. These can be very important when setting up the signature. Such as the CharSet Field. The EntryPoint and SetLastError can be pretty helpful too.

2. The MarshalAsAttribute Class is a very important part of creating a correct signature for the windows api functions and structures too. You need to know how to marshal the data types correctly.

3. The StructLayoutAttribute Class is also a must for using unmanaged structures in your managed code.

4. Add a little info on the difference between the "W" Unicode and "A" ANSI versions of some functions. That kind of fits into setting the CharSet and/or Marshaling Strings. These i mentioned in 1 and 2 above.

5. Throw a little info in there about using the IntPtr Structure. So the reader understands that an Integer or Long is not to be used for the handles to such things as a window.

6. It would also be good to throw in some info on the Marshal Methods such as the AllocCoTaskMem, AllocHGlobal, FreeCoTaskMem, FreeHGlobal, and Copy methods which are used quite often too.

7. Show them a table such as Table 1 near the bottom of the link below so they can find a managed .Net data type that is comparable to the unmanaged type shown in the C++ msdn documents. This would help them see how you came up with your data types in your managed conversion example.
Using P/Invoke to Call Unmanaged APIs from Your Managed Classes

8. Perhaps give them a link to the PInvoke Signature Toolkit which can be used to convert the C++ functions to the .net signatures. It has more very useful options too. Check it out, i use it on a daily basis almost.

I will let you digest some of that for now. If you would like more i will think up some more stuff that might be helpful/useful to include.
Was This Post Helpful? 0
  • +
  • -

#6 JacobH  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 26
  • View blog
  • Posts: 176
  • Joined: 07-September 15

Re: Looking for input on my content

Posted 19 July 2016 - 08:31 PM

@odi123_1 Great points. I especially agree with your points that it is worth it to include that kind brief summary of all the aspects in the content even if just purely for selfish reasons (more traffic). I plan to do so in my next entry. That is why I created the thread after all, to read and consider advice to improve my content. I find Pinvoke and the Win32API to be kind of a special case though. I can not imagine a case where I find it appropriate to write about using C#/.NET interop features, and the basics of Win32 API.

If you have wrote any windows desktop program past Hello World, you are familiar with what it is/why its useful. If you have not wrote any windows desktop apps past hello world, then the complexity of using unmanaged code in a managed language is the last place you want to be starting out. They are two separate things one must learn about, I think anyways. Even just explaining that assumption and reasoning at the start of the entry with links to get started on Win32 API basics would be much better than what I did though :) next time.

@IronRazer

Good suggestions, thanks. I am considering splitting it into multiple articles, for now my ideal goal is to give people content that gets their interest started enough to where they start investigating/experimenting/writing related code on their own. I am not sure multiple articles is best for that aim, but I want to experiment with it.

P.S, you seem to have a good understanding of C#/C++ and its interop features, so maybe you will be interested in my odd ball project on Git that uses a lot of interop code to do some neat things in C#. Its just called Process.NET on git search c# project, maybe worth a peak :).
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1