Traduction d'un code C++ en C# pour récupérer des données encodées dans le Clipb
thegodone
Messages postés2Date d'inscriptionmardi 29 mai 2007StatutMembreDernière intervention13 juillet 2009
-
13 juil. 2009 à 08:15
krimog
Messages postés1860Date d'inscriptionlundi 28 novembre 2005StatutMembreDernière intervention14 février 2015
-
17 juil. 2009 à 10:13
Bonjour,
Je cherche à récupérer l'object CDX embedded dans Word afin d'extraire ces données dans une forme windows en c#.
Je n'ai pas réussi à obtenir un Cast sur le COM de chemdraw toujours des erreurs de type:
Unable to cast COM object of type 'System.__ComObject' to interface type 'ChemDraw.Application'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{4E53CB60-4A53-4CBD-BA5D-FF7CB17E8319}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
qui me dit qu'il est possible d'extraire du clipboard "le dit" CDX voici le code en c++:
#define kScrapCommentKind 100
#define kScrapIDSize 5
static void DoMyComment(short kind, short dataSize, unsigned char *theData, string *theCDX)
{
// It's ours if it has the right comment kind, and begins with the ScrapID.
if (commentKind != kScrapCommentKind)
return;
if (dataSize < kScrapIDSize)
return; // not long enough
thegodone
Messages postés2Date d'inscriptionmardi 29 mai 2007StatutMembreDernière intervention13 juillet 2009 13 juil. 2009 à 12:00
rebonjour,
Je viens de trouver un programme qui m'a donné une traduction approximative:
private static void DoMyComment(short kind, short dataSize, ref byte theData, ref string theCDX)
{ // It's ours if it has the right comment kind, and begins with the ScrapID.
if (commentKind != DefineConstants.kScrapCommentKind)
return;
if (dataSize < DefineConstants.kScrapIDSize)
return; // not long enough
//C++ TO C# CONVERTER TODO TASK: The memory management function 'memcmp' has no equivalent in C#:
if (memcmp(theData, "CDIF", DefineConstants.kScrapIDSize) == 0)
;
//C++ TO C# CONVERTER TODO TASK: The append method is not converted to C#:
private static int Picture__EnumCommentsEMF(IntPtr theDC, ref HANDLETABLE table, CONST ENHMETARECORD mr, int nObj, IntPtr theCDX)
{ // CSC records are escaped comments { int length = mr->nSize - 3 * sizeof(mr->dParm[0]);
if (mr.iType == EMR_GDICOMMENT)
if (length > 0 && theCDX != null)
{
byte theData = (byte) mr.rdParm[1];
DoMyComment(DefineConstants.kScrapCommentKind, length, ref theData, ref (string)theCDX);
}
}
private return 1 ;
}
private string ExtractCDXFromPicture(IntPtr enhmetafile)
{
string theCDX;
RECT r = new RECT(0, 0, 9999, 9999);
int res = EnumEnhMetaFile(null, enhmetafile, Picture__EnumCommentsEMF, (IntPtr) theCDX, r);
}
Je ne trouve pas de fonctions equivalentes en c# pour la comparaison memcmp en mémoire et rien sur une méthode de modification de la chaine par un append comme en c++ avez vous des suggestion