In my application a user can have multiple documents open and print all documents to PDF's using a "Microsoft print to pdf" option when they are prompted at the print dialog window, after which they choose the destination folder. Now what happens is that if there are 30 documents selected for print, an inconsistent amount are successfully printed to pdf in the desired folder each time it is run. Sometimes all are successful and other times not. I found that files with unicode character names like this "敥敥敥敥敥敥敥敥" where being created in the same directory as the file of code that contains this print to pdf process. I can rename these files with a ".pdf" extension and they are working pdf documents.
Here is the part of code concerned:
DOCINFO docInfo;
memset(&docInfo, 0, sizeof(docInfo));
docInfo.cbSize = sizeof(docInfo);
docInfo.lpszDocName = csPlanoName;
docInfo.lpszOutput = csOutputDir + csPlanoName + csExtension;
if(dc.StartDoc(&docInfo) > 0) {
//printing process continues
}
I found that by stepping through the code, the StartDoc function call would change docInfo.lpszOutput to the same unicode characters "敥敥敥敥敥敥敥敥". This would not happen all the time, and does not happen with specific files when testing. One test a document will print to pdf successfully, another test with the same document and it will create the file with the name "敥敥敥敥敥敥敥敥".
Any help with this would be greatly appreciated.
Regards,
Chris
What are csPlanoName csOutputDir? docInfo.lpszDocName and docInfo.lpszOutput must be pointers to null-terminated strings and since you are using csOutputDir + csPlanoName + csExtension that won't work with regular pointers something else might be happening here. Make sure that result of csOutputDir + csPlanoName + csExtension is not getting implicitly cast to pointer and then going out of scope.
using a string conversion macro seems to have solved my problem, successfully tested outcome 10+ times.
CString csFullpath = csOutputDir + csPlanoName + csExtension;
docInfo.lpszOutput = CT2W(csFullpath);
Related
If personal information is included in the requested print using C++ language, cancel the current print and print again after receiving approval from the server.
※This event is raised when the user directly outputs an open file.
(In other words, if the user directly requests printing of an open file in the same way as ctrl+p, printing will be requested for the open file because the dll I created works.)
Approval is at EndDoc, the point at which the print is almost finished.
The problematic part is how to print again.
I was using the implementation to request a print again as shown below.
[refer to variable]
RequestDevModeW -> When printing is requested for the first time, the information is saved and used for reprint. (Saved when calling DocumentPropertiesW API.)
RequestDOCInfoW -> When printing is requested for the first time, the information is saved and used for reprint. (This is a structure stored in StartDocW when requesting a print for the first time.)
nPageCnt -> The number of startpage <-> Endpage is stored when the first print request is made.
[Code]
//... skip ...//
hReprintDC = CreateDCW(NULL, wszPrintName, NULL, &RequestDevModeW);
if (hReprintDC)
{
RequestDOCInfoW.lpszDocName = (LPCWSTR)wszDocName;
StartDocW(hReprintDC, &RequestDOCInfoW);
for (int nPage = 0; nPage < nPageCnt; ++nPage)
{
StartPage(hReprintDC);
EndPage(hReprintDC);
}
EndDoc(hReprintDC);
DeleteDC(hReprintDC);
g_hRePrintDC = NULL;
}
//... skip ...//
However, the code above is causing an error when displaying textbox in some documents (excel, word).
So I used the ShellExecuteEX API.
It prints very well, but I can't get the print attributes to work.
What I mean by print properties is that you have no control over these details, such as printing specific pages.
I'm curious about how to make a detailed request for a print using C++ code.
In addition, the print dialog should be output as it is with the existing specifications without being displayed.
When Running my code I really only want to display the code I'm working on. I don't want to display what seems to be the folder address. Is there a way to not display that?
I mean when im running my code. I want to see the answer to my code only so to just display
28
.... not the folder name desktop/cpp etc etc
I noticed you were having some trouble with VS-Code.
Here's a good list of commands which can complete your task.
I noticed you stated that you were on a Mac as well, so more than likely the CTRL + option won't be necessary; try the " ⌘ + " instead!
To remove / hide the folder explorer window, simply hit "⌘ + b"
To remove / hide the terminal as well, try using "⌘ + `"
Edit:
I noticed you were also having some issues with the output of your code. The "addresses" to your output are symbols that ( usually ) address incorrect operations.
Try doing something like this when writing out your function:
printf( "i%\n" ); // <- Adding a newline to the operation deducts the symbol.
I hope this helps-
I am running libsvm through weka. Its output accuracy looks good to me, so I am planning to write a svm model by myself. However, weka didn't generate any training parameter, such as number of support vector. Therefore i cannot do anything. Searching the web, i found somebody said it would generate some parameters like the following:
optimization finished, #iter = 27
nu = 0.058475864943863545
obj = -1.871013102744184, rho = -0.19357337828800944
nSV = 9, nBSV = 0 `enter code here`
Total nSV = 9
but how come i didn't see any of them? any step that i missed? please help me. Thanks a lot.
Weka writes the output you mentioned to stderr.
So if you have started weka.sh or weka.bat from a terminal (or "command window" if you are on Windows), you should see that output appear in your terminal window after clicking "classify"
If you want to have access to this information via scripts, you can
redirect the output to a file and read in that file.
Here is how to edit the startup file weka.sh / weka.bat.
Edit this line (it is probably the last line) in order to write log info to a file instead of the terminal window:
java -cp $CP -Xmx8092m weka.gui.GUIChooser 2>>/opt/weka-stable/weka.log &
You can also add a properties file to your home directory to add more fine-grained behaviour.
https://weka.wikispaces.com/Properties+file
(You probably can also access information via the Weka Java API somehow, but you did not ask for that)
So I have a software program that for reasons that are beyond this post, I will not include but to put it simply, I'd like to "MOD" the original software. The program is launched from a Windows Application named ViaNet.exe with accompanying DLL files such as ViaNetDll.dll. The Application is given an argument such as ./Statup.cat. There is also a WatchDog process that uses the argument ./App.cat instead of the former.
I was able to locate a log file buried in my Windows/Temp folder for the ViaNet.exe Application. Looking at the log it identifies files such as:
./Utility/base32.atc:_Encode32 line 67
./Utilities.atc:MemFun_:Invoke line 347
./Utilities.atc:_ForEachProperty line 380
./Cluster/ClusterManager.atc:ClusterManager:GetClusterUpdates line 1286
./Cluster/ClusterManager.atc:ClusterManager:StopSync line 505
./Cluster/ClusterManager.atc:ConfigSynchronizer:Update line 1824
Going to those file locations reveal files by those names, but not ending with .atc but instead .cat. The log also indicates some sort of Class, Method and Line # but .cat files are in binary form.
Searching the program folder for any files with the extension .atc reveals three -- What I can assume are uncompiled .cat files -- files. Low and behold, once opened it's obviously some sort of source code -- with copyright headers, lol.
global ConfigFolder, WriteConfigFile, App, ReadConfigFile, CreateAssocArray;
local mgrs = null;
local email = CreateAssocArray( null);
local publicConfig = ReadConfigFile( App.configPath + "\\publicConfig.dat" );
if ( publicConfig != null )
{
mgrs = publicConfig.cluster.shared.clusterGroup[1].managers[1];
local emailInfo = publicConfig.cluster.shared.emailServer;
if (emailInfo != null)
{
if (emailInfo.serverName != "")
{
email.serverName = emailInfo.serverName;
}
if (emailInfo.serverEmailAddress != "")
{
email.serverEmailAddress = emailInfo.serverEmailAddress;
}
if (emailInfo.adminEmailAddress != null)
{
email.adminEmailAddress = emailInfo.adminEmailAddress;
}
}
}
if (mgrs != null)
{
WriteConfigFile( ConfigFolder + "ZoneInfo.dat", mgrs);
}
WriteConfigFile( ConfigFolder + "EmailInfo.dat", email);
So to end this as simply as possible, I'm trying to find out two things. #1 What Programming Language is this? and #2 Can the .cat be decompiled back to .atc. files? -- and vice versa. Looking at the log it would appear that the Application is decoding/decompiling the .cat files already to interpret them verses running them as bytecode/natively. Searching for .atc on Google results in AutoCAD. But looking at the results, shows it to be some sort of palette files, nothing source code related.
It would seem to me that if I can program in this unknown language, let alone, decompile the existing stuff, I might get lucky with modding the software. Thanks in advance for any help and I really really hope someone has an answer for me.
EDIT
So huge news people, I've made quite an interesting discovery. I downloaded a patch from the vendor, it contained a batch file that was executing ViaNet.exe Execute [Patch Script].atc. I quickly discovered that you can use Execute to run both .atc and .cat files equally, same as with no argument. Once knowing this I assumed that there must be various arguments you can try, well after a random stroke of luck, there is one. That being Compile [Script].atc. This argument will compile also any .atc file to .cat. I've compiled the above script for comparison: http://pastebin.com/rg2YM8Q9
So I guess the goal now is to determine if it's possible to decompile said script. So I took a step further and was successful at obtaining C++ pseudo code from the ViaNet.exe and ViaNetDll.dll binaries, this has shed tons of understanding on the proprietary language and it's API they use. From what I can tell each execution is decompiled first then ran thru the interpreter. They also have nicknamed their language ATCL, still no idea what it stands for. While searching the API, I found several debug methods with names like ExecuteFile, ExecuteString, CompileFile, CompileString, InspectFunction and finally DumpObjCode. With the DumpObjCode method I'm able to perform some sort of dump of script files. Dump file for above script: http://pastebin.com/PuCCVMPf
I hope someone can help me find a pattern with the progress I made. I'm trying my best to go over the pseudo code but I don't know C++, so I'm having a really hard time understanding the code. I've tried to seperate what I can identify as being the compile script subroutines but I'm not certain: http://pastebin.com/pwfFCDQa
If someone can give me an idea of what this code snippet is doing and if it looks like I'm on the right path, I'd appreciate it. Thank you in advanced.
I am trying to implement this person's code: http://iris.lib.neu.edu/civil_eng_theses/30/ but I can not generate a working executable in visual studio because I am missing 2 files: myoutput.cpp and PrintTimeReferencedVariable.cpp. I am unclear if the Matlab builder is supposed to generate them or I write them.
The myoutput.cpp is supposed to be a C++ file that does essentially a dlmwrite. It is used as follows:
function [] = Output_01(FileName, FileNameLenght, OutputData, OutputSize1, OutputSize2)
coder.inline('never')
coder.ceval( 'myoutput', FileName, FileNameLenght, OutputData, OutputSize1, OutputSize2);
end
% %% Matlab Version: to run the model in Matlab uncomment below, comment above
% function [] = Output_01(FileName, FileNameLenght, OutputData, OutputSize1, OutputSize2)
% dlmwrite(FileName, OutputData,'-append','coffset',0,'delimiter','\t','precision','%6.6G')
% precision = 4;
% disp( num2str( OutputData,precision))
% end
Where the commented out is the matlab version of the file and the top is what is built into C++. The files are supposed to write to the directory: C:\matlab-results-from-cpp.
The PrintTimeReferencedVariable.cpp looks like a date function that should do:
% Date = datestr(now, 'yyyy-mm-dd-HH-MM-SS' );
%% Matlab Version: to run the model in Matlab uncomment above, comment below
Date = '2012-09-16-09-19-20';
coder.ceval('PrintTimeReferencedVariable', coder.wref(Date));
Any insight into this would be much help. I'm still waiting to hear back from the author but it would still be helpful to hear all of your input as this is my first time in C++ and building projects in Matlab.
Thanks!
Seems like the text is pretty clear on what you do, though I can understand the confusion not coming from a C++ background:
5)
“Project Settings ”adjustments: Open ‘More settings’,then in ‘All Settings’ tab, choose for ‘Language’ C ++; In “Speed” tab mark only “Saturate on integer overflow”, unmark everything else; in “Custom Code ” tab, copy and paste the first lines the functions “myoutput.cpp” and “PrintTimeReferencedVariable.cpp”, followed by semicolon or see below the text:
void PrintTimeReferencedVariable (char * DateOut);
void myoutput(const char* _filename, int fileNameLen, double* data, int n, int m);
So you create the files "myoutput.cpp" and "PrintTimeReferencedVariable.cpp". Copy and paste the code into the respective cpp files. Then add the prototype(the second quote) to your header or at the top of those files.