Problem about setting IOTTYBaseName in USBSerialDriverKit - driverkit

I want know how to set IOTTYBaseName in USBSerialDriverKit.I try to use SetProperties method inherit from IOService like following code, but the methodreturn -301 error code.
super::CopyProperties(&pDict);
bResult = OSDictionarySetValue(pDict, kIOTTYBaseNameKey, tty_name);
if(bResult) {
PL_OSLOG("SET TRUE");
} else {
PL_OSLOG("SET FALSE");
}
result = super::SetProperties(pDict);
enter image description here

Related

TWebBrowser QueryInterface IID_IHTMLElement2 always returns E_NOINTERFACE

I am doing a simple QueryInterface() to get the IHTMLElement2 interface, but it always fails with E_NOINTERFACE.
UPDATE: I need to get the IHTMLElement2 interface of the body element because it has a focus() method so I can set focus to the body. It can't be done with the IHTMLElement interface.
Any ideas why this errors (or how to reach body->focus())?
WebBrowser1->Navigate(L"c:\\test.htm");
while (WebBrowser1->Busy) Application->ProcessMessages();
DelphiInterface<IHTMLDocument2> diDoc = WebBrowser1->Document;
if (diDoc) {
DelphiInterface<IHTMLElement2> diBodyElement;
// all good until this point
if (SUCCEEDED(diDoc->QueryInterface(IID_IHTMLElement2, reinterpret_cast<void**>(&diBodyElement))) && diBodyElement) {
// Never reaches this part - always E_NOINTERFACE when querying for IID_IHTMLElement2
diBodyElement->focus();
}
}
I've reached my own solution how to reach body->focus() which follows:
DelphiInterface <IHTMLDocument2> diDoc2 = WebBrowser1->Document;
if (diDoc2) {
DelphiInterface<IHTMLElement> pBody1;
DelphiInterface<IHTMLElement2> pBody2;
DelphiInterface<IHTMLBodyElement> pBodyElem;
if (SUCCEEDED(diDoc2->get_body(&pBody1)) && pBody1) {
if (SUCCEEDED(pBody1->QueryInterface(IID_IHTMLBodyElement, reinterpret_cast<void**>(&pBodyElem))) && pBodyElem) {
if (SUCCEEDED(pBodyElem->QueryInterface(IID_IHTMLElement2, reinterpret_cast<void**>(&pBody2))) && pBody2) {
pBody2->focus();
}
}
}
}
EDIT (suggested by Reby Lebeau) - simplified version:
DelphiInterface <IHTMLDocument2> diDoc2 = WebBrowser1->Document;
if (diDoc2) {
DelphiInterface<IHTMLElement> pBody1;
DelphiInterface<IHTMLElement2> pBody2;
if (SUCCEEDED(diDoc2->get_body(&pBody1)) && pBody1) {
if (SUCCEEDED(pBody1->QueryInterface(IID_IHTMLElement2, reinterpret_cast<void**>(&pBody2))) && pBody2) {
// focus to <body> element
pBody2->focus();
}
}
}

Setting URL in UploadCollectionItem in UI5 1.38.4

What parameters are mandatory for an UploadCollectionItem with the URL parameter set will show the file when the filename is clicked.
I am using a factory to handle files coming from different locations.
attachmentFactory(sId, context) {
const modelObj = context.getModel().getProperty(context.getPath());
const uploadListItem = new SAPUploadCollectionItem();
// If __metadata exists, attachment entry is from odata, if not then it's a FileEntry object.
if (modelObj.__metadata) {
uploadListItem.setFileName(modelObj.FILE_NAME);
uploadListItem.setMimeType(modelObj.MIME_CODE);
uploadListItem.setUrl("https://upload.wikimedia.org/wikipedia/commons/4/49/Koala_climbing_tree.jpg");
}
else {
uploadListItem.setFileName(modelObj.name);
uploadListItem.setMimeType(modelObj.type);
uploadListItem.setUrl("https://upload.wikimedia.org/wikipedia/commons/4/49/Koala_climbing_tree.jpg");
}
return uploadListItem;
}
I get an exception in UI5 when I press the link in the function
UploadCollection.prototype._triggerLink = function(oEvent, oContext) {
var iLine = null;
var aId;
if (oContext.editModeItem) {
//In case there is a list item in edit mode, the edit mode has to be finished first.
sap.m.UploadCollection.prototype._handleOk(oEvent, oContext, oContext.editModeItem, true);
if (oContext.sErrorState === "Error") {
//If there is an error, the link of the list item must not be triggered.
return this;
}
oContext.sFocusId = oEvent.getParameter("id");
}
aId = oEvent.oSource.getId().split("-");
iLine = aId[aId.length - 2];
sap.m.URLHelper.redirect(oContext.aItems[iLine].getProperty("url"), true);
};
oContext.aItems is an array but the source.getId() value is "__item9-ta_filenameHL" so __item9 is not found in oContext.aItems
I'm not sure if this is a bug or I'm setting up my UploadCollectionItem incorrectly
I had to set the sId of the UploadCollectionItem to be the sId that was passed into the factory.

avoid Number Format Exception while parseing to integer

I'm trying to check if the text area has only numbers or not, but i got this problem Number Format Exception while clicking on the Edit Button, any Ideas how to solve it.
ArrayList<CarRental> List= CarRent.getList();
String text=EditTF.getText().trim();
char [] txt=text.toCharArray();
Character a=null;
boolean isnotDigit=false;
int index;
for(int i=0;i<txt.length;i++)
{
if(!a.isDigit(txt[i]))
{
isnotDigit=true;
break;
}
else
{
isnotDigit=false;
continue;
}
}
if(isnotDigit==false)
{
index=Integer.parseInt(text.trim());
PrintList_Summary.setIndex(index);
EditDetails.nameTF.setText(List.get(index).getName());
EditDetails.sizeCOB.setSelectedItem(List.get(index).getSize());
EditDetails.daysTF.setText(List.get(index).getDays()+"");
if(List.get(index).getCarType().equalsIgnoreCase("Luxury"))
{
EditDetails.LuxRB.setSelected(true);
}
else if(List.get(index).CarType().equalsIgnoreCase("Truck"))
{
EditDetails.truckRB.setSelected(true);
}
if(List.get(index).getDriver())
{
EditDetails.yesRB.setSelected(true);
}
else
{
EditDetails.noRB.setSelected(true);
}
EditDetails.Frame.setVisible(true);
}
else
{
JOptionPane warning=new JOptionPane();
warning.showMessageDialog(null,"Element Index CAN ONLY be an INTEGER.","Invalid Index",WIDTH);
}
Use try catch to handle exceptions.
try{
index = Integer.parseInt(text.trim());
//etc
}catch(NumberFormatException ex){
//whatever happens when the exception is thrown (not an integer)
}
You can use that instead of the if(!a.isDigit(txt[i])) for. If it can't be parsed, then it will go intro the catch.
Also, you can use !isnotDigit instead of isnotDigit == false.
I would use String.matches() for your check instead of doing it yourself. Scrap the for-loop and change your if-condtion from isnotDigit==false to text.matches("[0-9]+"). After this Integer.parseInt(text) should definitly work.
This uses a regular expression to check if your string consists only of digits and at least one digit. For further reference on regular expression see the javadoc for Pattern.

Window services cant run exe on trigger time

I make one window service in c#
to run exe on particular time., but it could open that exe,
Below is code
private static string checkdatentime()
{
currentdate = DateTime.Now;
string value = "1";
for (int i = 0; i < xml_date.Count; i++)
{
value = "2";
if (currentdate.Date < xml_date[i].Date)
{
value = "3";
break;
// go out side for loop;
}
else if (currentdate.Date > xml_date[i].Date)
{
value = "4";
//Do nothing means loops continues
}
else
{
value = "5";
//if both date are same
if (currentdate.Date == xml_date[i].Date)
{
value = "99";
currentTime = currentdate.ToString("hh:mm");
TriggerTime = newItem.TriggerTime.ToString("hh:mm");
if (currentTime == TriggerTime)
{
value = "6";
//Run EXE
System.Diagnostics.Process.Start("E:\\SqlBackup_Programs\\console-backup\\Backup_Console_App 22July Latest\\Backup_Console_App\\Backup_Console_App\\bin\\Debug\\Backup_Console_App");
return value;
}
}
}
}
return value;
}
NOTE: here I return value because to verify is my code runs correct or not and write VALUE on text file, so on same time I am getting VALUE=6, means there is no problem in code,
But still service cant open this exe,
by same code i made console application and its runs perfectly, so why not services??
Is this any problem with command,
System.Diagnostics.Process.Start();
kindly help me!!
I got the answer, I had checked the option "Allow to interact with the Desktop" in the Windows service properties
And now its Working

CommandBars.FindControl throwing an exception

I am trying to use the FindControl Method of the CommandBars object in a VSTO Word addin to get what else a command bar object
Code is as follows
private void WireContextMenu(string MenuID,string Tag, string ID, ref Office.CommandBarButton Control)
{
try
{
object missing = System.Type.Missing;
Control = (Office.CommandBarButton)this.Application.CommandBars[MenuID].FindControl((object)Office.MsoControlType.msoControlButton, ID, Tag, missing, missing);
if (Control == null)
{
Control = (Office.CommandBarButton)this.Application.CommandBars[MenuID].Controls.Add(Office.MsoControlType.msoControlButton, ID, missing, missing, missing);
Control.Caption = "Biolit Markup Selection";
Control.Tag = Tag;
}
Control.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(this.cb_Click);
}
catch (Exception Ex)
{
}
}
The FindControl method is throwing a Type Mismatch Exception (-2147352571)
Any ideas
is this the right way anyhow to add a item to the right click menu of word and then make sure you dont add it if it already exists
Thanks
you are using Missing where Missing is not allowed as parameter
ref: link text
http://msdn.microsoft.com/en-us/library/system.type.missing.aspx
use code like this:
object type = MsoControlType.msoControlPopup;
object id = 1;
object tag = null;
object visible = 1;
object recusive = false;
//object missing = System.Type.Missing;
CommandBarControl barControl = popParent.FindControl(type, id, tag, visible, recusive);