.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

HowTo Marshal C++ enums and copy buffer of unsigned 16bit integer

Posted By:      Posted Date: September 23, 2010    Points: 0   Category :.NET Framework

Hi together,

I'm trying to wrap an API of a digital camera SDK (unmanaged C++). Some of the functions a working, but some of them ... :(

1. HowTo marshal  C++  enums?

This is a part of the api.h file:



	DCAM_DATATYPE_UINT8	=	0x00000001,	/* bit 0 */
	DCAM_DATATYPE_UINT16	=	0x00000002,	/* bit 1 */
	DCAM_DATATYPE_UINT32	=	0x00000008,	/* bit 3 */
	DCAM_DATATYPE_MOSAIC8	=	0x00010000,	/* bit 16, 8bit mosaic */
	DCAM_DATATYPE_MOSAIC16	=	0x00020000,	/* bit 17, 16bit mosaic */
	DCAM_DATATYPE_RGB24	=	0x00040000,	/* bit 18, 8bit*3, [ r0, g0, b0], [r1, g1, b1] */
	DCAM_DATATYPE_RGB48	=	0x00100000,	/* bit 20, 16bit*3, [ r0, g0, b0], [r1, g1, b1] */


BOOL DCAMAPI dcam_getdatatype			( HDCAM h, DCAM_DATATYPE* pType );
BOOL DCAMAPI dcam_setdatatype			( HDCAM h, DCAM_DATATYPE type );<br/>


And this is what I wrote in C#:

View Complete Post

More Related Resource Links

Marshall Copy a C++ ushort buffer into a C# ushort buffer.

I have a C++ dll that returns an unsigned short data buffer. I want to copy this data using my C# copy however the Marshall.Copy only supports "short" data type. What is the most efficient way to to get this data into a ushort buffer in C#?

geting string from integer using enums


we know 

The .NET Framework contains an Enum called DayOfWeek.

so now if i have an integer 7
how can i ge the string "Saturday" using  the enum

Read data with Marshal.Copy



Is it possible to read part of data with Marshal.Copy?

I am using Marshal.Copy in my code the following way,

Marshal.Copy(ptrData, dest, startIndex, size); // dest array is a 'byte' array

Suppose, ptrData holds  a data of length 100. And I want to read data starting from 10th location with length of data is 5.


I don't think I can do this Marshal.Copy as none of the parameters in this function accepts 'StartIndex' in source.


The parameters in Marshal.Copy are:

  The memory pointer to copy from.

  The array to copy to.

  The zero-based index into the array where Copy should start.

  The number of array elements to copy.

So, is there any way we can copy the range of data from source pointer.



Integer Validation



I need to make validation for Textbox to allow enter integer stated by 9 or 6 or 5 , and also maximum 8 digits , how to do that ?





How to cast integer values as an array of enum values?


Hello all!

I'm working with VS2010 Beta2, ASP.NET and Dynamic Data. I'm using VB but will certainly be happy to receive a C# example if necessary. Laughing

I used a few of Steve's examples (Writing Attributes and Extension Methods for Dynamic Data and Dynamic Data - Hiding Columns in selected PageTemplates) to create a custom property attribute to be applied to a dynamic data column and want it to accept an array of enum values (each value will represent a dynamic data page template where this column should not be displayed).  My new attribute works fine when I hardcode it like this, meaning the HideColumnIn attribute is properly populated with the array of enum values:

<HideColumnIn(PageTemplate.List, PageTemplate.Edit)> _
Public Property My_DD_Column As Object


However, I want to store the values to be used for the HideColumnIn in the DB as integer values that correspond to the

Visual Web Developer 2010 Express "Copy Web Site" using different login


I created a site and am trying to grant another pesron access to upload changes to it without giving them my super-user login.

I made a login for her but I can't test whether it works or not because no matter how much I "disconnect" in the Copy Web Site page of VWD 2010, reconnecting to the same site always logs in as my superuser account without prompting me for a login again.

How do I test is the account it set up correctly before having her try to upload to it?    I want to force the login to remote site dialog to pop up again to test her account.

Any ideas?

Bulk Copy From Datatable To SQL Server Table


 I have read the data of a excle file and captured the data into the dataset to a datatable, now that data is to be inserted into a SQL Server table using bulk copy option. I am using -

 public bool BulkEnterData(DataTable dt, string tblName)
        SqlBulkCopy bulk = new SqlBulkCopy(con);
        bulk.DestinationTableName = tblName;

        return true;

ERROR Getting-
A transport-level error has occurred when receiving results from the server. (provider: Shared Memory Provider, error: 0 - The pipe has been ended.) 

How to resolve the above problem or any other solution is available.


Cutting Edge: All About Enums


Dino Esposito reviews the basics of enumeration types and their implementation in the Microsoft .NET Framework.

Dino Esposito

MSDN Magazine August 2006

Bulk Copy Operations in ADO.NET 2.0


Bulk copying of data from one data source to another data source is a new feature added to ADO.NET 2.0. Bulk copy classes provides the fastest way to transfer set of data from once source to the other.

Each ADO.NET data provider provides bulk copy classes. For example, in SQL .NET data provider, the bulk copy operation is handled by SqlBulkCopy class, which is described in Figure 1. As you can see from Figure 1, data from a data source can be copied to one of the four types - DataReader, DataSet, DataTable, or XML.

Unable to copy/move wiki pages with links to other wiki pages

When I try to copy or move wiki pages from one 'Wiki library A' to 'Wiki library B' through 'content and structure', I get an error for the pages which contain links to other wiki pages, does sameone has a clue how to fix this:

<error><message>Het item bestaat niet. Mogelijk is het door een andere gebruiker verwijderd.</message><full>Microsoft.SharePoint.SPException: Het item bestaat niet. Mogelijk is het door een andere gebruiker verwijderd. ---&gt; Microsoft.SharePoint.SPException: Het item bestaat niet. Mogelijk is het door een andere gebruiker verwijderd. at Microsoft.SharePoint.SPListItem.EnsureItemIsValid() at Microsoft.SharePoint.SPListItem.PrepareItemForUpdate(Guid newGuidOnAdd, Boolean bMigration, Boolean&amp; bAdd, Boolean&amp; bPublish, Object&amp; objAttachmentNames, Object&amp; objAttachmentContents, Int32&amp; parentFolderId) at Microsoft.SharePoint.Deployment.ListItemSerializer.AddOrUpdateDoclibItem(SerializationInfoHelper infoHelper, SPListItem&amp; listItem, SPWeb web, Guid newId, String&amp; listItemServerRelativeUrl, Boolean bIsPublish, Boolean exists, StreamingContext context, ISurrogateSelector selector, ImportObjectManager objectManager) at Microsoft.SharePoint.Deployment.ListItemSerializer.SetObjectData(Object obj, SerializationInfo info, StreamingContext context, ISurr

Cannot copy document to other library

When I try to send a document to another SharePoint library (Send To>Other Location) I am receiving a blank message box.  Does anyone have an idea what the empty message box is about or why this error is occurring?  Thank you!

Invalid URL"" after copy or move a document.



We have an website that have 3 libraries. The "first Library" is used only to edit documents and it's called "my documents". When a user finish of edit your documents here, they start a workflow that will check fields in the document and move the document for the second library (using Sharepoint Designer Workflow - without custom actions).
In "second library" we have a big workflow. This WF has some steps for approve, collect feedback, generate sub-tasks and others things related for the document. This WF use many custom actions in (Sharepoint Designer).
When this WF arrives to the end, the document is moved to "third library", that is a official repository of documents in the enterprise.
The entire cycle works fine. But when someone creates a internal copy of the document in the "first library" to begin again the flow, we receive a Invalid Url error. It occurs when any update operations is executed over the document item, the value is conserved but the error is displayed. After it, we can not execute other workflows over the item.
If we save the document in local disk, delete the library item, and then upload it again, the problem is solved.

Some one have an idea about why and how solve it?  We are using WSS 3.0.

The following is an error registred in log file when you d

Check-out issue when opening a document from a document library when a read-only copy is open

We have an issue when a user has a read-only copy of a document from SharePoint open and then tries to check-out and edit another copy of the document (i.e. from the document library) the checked out copy is not connected to the web server. For the user it will look the same they will make edits, save and then close, but when they do so the document is not updated in SharePoint - it may be saved locally in their SP drafts, but the user will think that they have lost their version. We then get the checked out to another user error and you have to discard changes to get the document working again. Steps to reproduce this issue: * click on the name of a office doc on a Document Library * Make sure "Read Only" is selected and click "ok" * Minimize open document * click on the same file on the Document Library * Make sure "check out and edit" is selected and the "Use my local drafts folder" checkbox is ticked. Select OK. * Edit document and press save. Changes are never saved back in SharePoint, they are only on the local draft. We are using MOSS with SP2. Clients are on Office 2003 and 2007 Is this normal behaviour? Is there anything that can be done to prevent this from happening?

Copy the content of one form library to another form library



I have created a form library named "A" where I store all the info-path forms submitted by a certain group of people. In that form library I created a column "status". When the form is submitted the value of status will be "0". Once a person approves this form I am changing the status value to "1". If the value is changed to "1", that form should be copied or transferred to another form library named "B".

How can I implement this logic ? Any help...

SharePoint Wiki HowTo Template



was wondering if anyone has or has suggestion on the following:

we are contemplating creating a wiki type howto for our users which needs to be categoriesed into permission level (eg user, super user, admin).

We would quite like to have the ability to add content, and then link the relevent catories to it (done via a lookup at moment).

And relevent video (e.g embeded you tube).


The video part I am thinking of a library with a field type that allows embed (do you know of any?).  On the wiki page I quite like it if the video would show rather an having to navigate to them, but doubt this is possible.


I know wiki can't have a uniformed template due to the way they are produced and web parts have to be added manually.  Does this mean are idea would maybe be better as a publishing site with a custom template?

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend