When using the HookPrinter SDK product, I encountered an issue where it failed to copy some SPL files. Upon further investigation, I discovered that certain SPL files had the same "filetime," indicating that their file creation times were identical. This is an unusual occurrence.
https://www.verypdf.com/app/hookprinter/index.html
The problem arises from multiple SPL files having the same "filetime" in the "C:\windows\system32\spool\PRINTERS" folder. This folder may contain SPL files from various print jobs. When HookPrinter SDK attempts to determine the latest file based on the largest "filetime," it encounters ambiguity when multiple SPL files share the same "filetime." Consequently, it cannot identify which file is the most recent, leading to the problem.
Screenshot 1:
Screenshot 2:
In your example:
- "FP00970.SPL" belongs to Print JobID 207.
- "FP00971.SPL" belongs to Print JobID 208.
- "FP00972.SPL" belongs to Print JobID 209.
To address this issue, you can resolve to copy out all SPL files from the "C:\windows\system32\spool\PRINTERS" folder directly. Follow these steps to implement this solution:
1. Develop an EXE application to copy all SPL files from the "C:\windows\system32\spool\PRINTERS" folder to your designated folder. After copying, delete the SPL files from the "C:\windows\system32\spool\PRINTERS" folder. Below is a C/C++ source code example:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <windows.h>
// Function to check if a file ends with a certain extension
int endsWith(const char *str, const char *suffix) {
size_t str_len = strlen(str);
size_t suffix_len = strlen(suffix);
return (str_len >= suffix_len) && (strcmp(str + (str_len - suffix_len), suffix) == 0);
}
// Function to copy a file
void copyFile(const char *source, const char *destination) {
CopyFileA(source, destination, FALSE);
}
// Function to delete a file
void deleteFile(const char *filename) {
DeleteFileA(filename);
}
int main() {
const char *sourceFolder = "C:\\windows\\system32\\spool\\PRINTERS\\";
const char *destinationFolder = "C:\\your_owned_folder\\";
WIN32_FIND_DATAA findFileData;
HANDLE hFind;
// Check if the destination folder exists, if not create it
CreateDirectoryA(destinationFolder, NULL);
// Start searching for files in source folder
char searchPath[MAX_PATH];
sprintf(searchPath, "%s*", sourceFolder);
hFind = FindFirstFileA(searchPath, &findFileData);
if (hFind != INVALID_HANDLE_VALUE) {
do {
if (endsWith(findFileData.cFileName, ".SPL")) {
// Copy the SPL file to destination folder
char sourceFile[MAX_PATH], destinationFile[MAX_PATH];
sprintf(sourceFile, "%s%s", sourceFolder, findFileData.cFileName);
sprintf(destinationFile, "%s%s", destinationFolder, findFileData.cFileName);
copyFile(sourceFile, destinationFile);
printf("Copied file: %s\n", findFileData.cFileName);
// Delete the SPL file from source folder
deleteFile(sourceFile);
printf("Deleted file: %s\n", findFileData.cFileName);
}
} while (FindNextFileA(hFind, &findFileData) != 0);
FindClose(hFind);
} else {
printf("Source folder does not exist.\n");
return 1;
}
return 0;
}
2. Compile the provided source code into an EXE file. Then, set the path of this EXE file in the VeryPDF-HookPrinter.ini file as follows:
------------------
[AutoSave]
strLicenseKey=XXXX-XXXX-XXXX-XXXX
bCaptureSPLFiles=1
strSPLOutputFolder=
strCmd=C:\your_owned_folder\your_exe_file.exe
------------------
Replace "XXXX-XXXX-XXXX-XXXX" with your actual license key for VeryPDF-HookPrinter. Set the "strCmd" parameter to the path of your compiled EXE file.
3. When you print a document, the HookPrinter SDK will invoke "C:\your_owned_folder\your_exe_file.exe". This executable will then easily copy all SPL files from the "C:\windows\system32\spool\PRINTERS" folder to your designated folder. Afterward, you can perform any desired operations on the copied SPL files.
We hope this solution proves useful to you. Feel free to give it a try!