Planet PDF Forum Archive

Planet PDF ForumWowsers! This is page is old, head to the LIVE Planet PDF Forum. It features more than 10 conferences, covering everything from beginner to in-depth developer and pre-press discussions. If you wish to continue... one & two archive covers 1999-2011 (160,000 pages).

New Forum | Previous | Next | (P-PDF) Developers

Topic: DocGoToNameDest not working
Conf: (P-PDF) Developers, Msg: 72123
From: paraggadgil
Date: 9/11/2002 02:12 AM

I need to open a pdf document directly at a bookmark location.
I tried using DocGoToNameDest as following c++ code, but it doesn't seem to be working.
Is there anything wrong with this code? or is there any other way of doing it?

Thanks in advance

long lRetCode;
HKEY hkey;
DWORD pathBuf[MAX_PATH + 1];
DWORD size = MAX_PATH + 1;
char *HelpFilename = "E:\\temp\\test.pdf";
char *NameDest = "Chapter 4 INFOConnect PEP";
int pagenum = 20;


// Determine if a PDF viewer is installed.
if (lRetCode == ERROR_SUCCESS) {

// Get the path to the viewer executable and launch it.
lRetCode = RegQueryValueEx (hkey, "", 0, 0, (unsigned char *)pathBuf, &size);
RegCloseKey (hkey);

STARTUPINFO startupInfo;
memset (&startupInfo, 0, sizeof(STARTUPINFO));
startupInfo.cb = sizeof(STARTUPINFO);

memset (&processInfo, 0, sizeof(PROCESS_INFORMATION));

// Launch the viewer.
CreateProcess ((const char *)pathBuf, NULL, NULL, NULL, false, NORMAL_PRIORITY_CLASS,
NULL, NULL, &startupInfo, &processInfo);

// Give application some launch time. A better approach is used in
// BuildIndexDde.cpp.
Sleep (8000);

} else {

// Advertise the problem and bail.
MessageBox (NULL,"No PDF Viewer installed. Aborting...", "DdeOpen - Error",MB_OK);
return -1;

char ddeCmdBuf[64];
UINT retVal;
DWORD id = 0;

// Start the DDE work now that the viewer is launched.
memset (ddeCmdBuf, 0, sizeof(ddeCmdBuf));
sprintf(ddeCmdBuf, "[DocOpen(\"%s\")]",HelpFilename);

retVal = DdeInitialize (&id, &DDE_ProcessMessage, APPCMD_CLIENTONLY, 0);
if (DMLERR_NO_ERROR == retVal) {

DWORD dwResult;
HCONV hConversation = NULL;
HSZ hszServerName, hszTopicName;

// Initialize DDE conversation with server.
hszServerName = DdeCreateStringHandle (id, ACRO_DDESERVER, 0);
hszTopicName = DdeCreateStringHandle (id, ACRO_DDETOPIC, 0);
hConversation = DdeConnect (id, hszServerName, hszTopicName, NULL);

retVal = DdeGetLastError (id);
if (DMLERR_NO_ERROR != retVal)
MessageBox (NULL, "Could not connect to server.", "DdeOpen - Error", MB_OK);
else {
// Execute the DDE Command.
DdeClientTransaction ((unsigned char *)ddeCmdBuf, (DWORD)strlen(ddeCmdBuf), (HCONV)hConversation,
memset (ddeCmdBuf, 0, sizeof(ddeCmdBuf));
sprintf(ddeCmdBuf, "[DocGoToNameDest(\"%s\",\"%s\")]",HelpFilename,NameDest);
DdeClientTransaction ((unsigned char *)ddeCmdBuf, (DWORD)strlen(ddeCmdBuf), (HCONV)hConversation,

UINT result = DdeGetLastError(id);

DdeDisconnect (hConversation);

// Release resources.
DdeFreeStringHandle (id, hszServerName);
DdeFreeStringHandle (id, hszTopicName);
DdeUninitialize (id);

} else
MessageBox (NULL, "Failed to initialize DDE.", "DdeOpen - Error", MB_OK);

return 0;

PDF In-Depth Free Product Trials Ubiquitous PDF

Debenu Aerialist

The ultimate plug-in for Adobe Acrobat. Advanced splitting, merging, stamping, bookmarking, and link...

Download free demo

Debenu PDF Tools Pro

It's simple to use and will let you preview and edit PDF files, it's a Windows application that makes...

Download free demo

Five visions of a PDF Day

In the world of PDFs or as we like to say Planet (of) PDF, a year isn't a real PDF year without an intense few days of industry knowledge sharing.

May 15, 2018
Platinum Sponsor

Search Planet PDF
more searching options...
Planet PDF Newsletter
Most Popular Articles
Featured Product

Debenu PDF Aerialist

The ultimate plug-in for Adobe Acrobat. Advanced splitting, merging, stamping, bookmarking, and link control. Take Acrobat to the next level.


Adding a PDF Stamp Comment

OK, so you want to stamp your document. Maybe you need to give reviewers some advice about the document's status or sensitivity. This tip from author Ted Padova demonstrates how to add stamps with the Stamp Tool along with related comments.