Roman пишет:Програмно вызвать dumpshx.exe, и выполнять разбор полученного shp файла?
Это было бы слишком. :) Я имел в виду непосредственный анализ shx-файла из твоей программы:
static void ShapeNames(void)
{
struct SHAPESTRUCT {
unsigned short iShapeNumber; // shape number
unsigned short iDefBytes; // number of data bytes in shape, 2000 max
unsigned char *lpszShapeName; // pointer to shapename
unsigned char *lpszSpecBytes; // pointer to shape specification bytes
};
char SHAPE10[] = "AutoCAD-86 shapes 1.0";
char SHAPE11[] = "AutoCAD-86 shapes 1.1";
resbuf *rbfile = NULL;
if (RTNORM == acedGetFileNavDialog("Select shape file","","shx","ShapeNames",0,&rbfile))
{
FILE *fshx = fopen(rbfile->resval.rstring,"rb"); acutRelRb(rbfile);
if (fshx) {
char desc[32];
fread (desc,sizeof(desc),1,fshx);
if (!strstr(desc,SHAPE10) && !strstr(desc,SHAPE11)) {
acutPrintf("\nIt is not shape file!");
fclose(fshx);
return;
}
fseek (fshx, (long)0x1c, SEEK_SET);
unsigned short iNumShapes = 0;
fread (&iNumShapes, sizeof (iNumShapes), 1, fshx);
SHAPESTRUCT *lpShapeList, *lpShape;
lpShapeList = (SHAPESTRUCT *)calloc(iNumShapes, sizeof (*lpShapeList));
for (int i=0; i < iNumShapes; i++) {
lpShape = lpShapeList + i;
fread(&(lpShape->iShapeNumber), sizeof (lpShape->iShapeNumber), 1, fshx);
fread(&(lpShape->iDefBytes), sizeof (lpShape->iDefBytes), 1, fshx);
}
if (lpShapeList->iShapeNumber != 0) { // Это файл формы
for (int i = 0; i < iNumShapes; i++) {
lpShape = lpShapeList + i;
lpShape->lpszShapeName = (unsigned char *)(malloc (lpShape->iDefBytes));
fread (lpShape->lpszShapeName, sizeof (*lpShape->lpszShapeName), lpShape->iDefBytes, fshx);
acutPrintf("\nShape N%d = %s", i, lpShape->lpszShapeName);
free(lpShape->lpszShapeName);
}
} else {
acutPrintf("\nIt is not shape file!");
}
free(lpShapeList);
fclose(fshx);
}
}
}
В этой этой программе не исключены ошибки, т.к. я ее переделывал из другой, но общая идея надеюсь понятна.